Cov txheej txheem:

Daim ntawv sau qoob loo yog dab tsi?
Daim ntawv sau qoob loo yog dab tsi?

Video: Daim ntawv sau qoob loo yog dab tsi?

Video: Daim ntawv sau qoob loo yog dab tsi?
Video: ib sim cas tsis tsim nyog tsom xyooj 2022 2024, Kaum ib hlis
Anonim

Dab tsi yog tsab ntawv noob ? larrywright on Dec 12, 2010 [-] A tsab ntawv uas populates koj database nrog ib txheej ntawm cov ntaub ntawv xeem. Nws tuaj yeem yooj yim li ib pawg ntawm INSERT cov lus, lossis qee yam ntau ntxiv.

Ua raws li qhov kev pom no, koj yuav ua li cas cog cov ntaub ntawv?

Database seeding yog qhov pib noob ntawm a database nrog cov ntaub ntawv. Seeding ib database yog ib tug txheej txheem uas pib cov ntaub ntawv yog muab rau a database thaum nws raug ntsia. Nws yog tshwj xeeb tshaj yog pab tau thaum peb xav populate lub database nrog cov ntaub ntawv peb xav tsim yav tom ntej.

Ib yam li ntawd, dab tsi yog seeding hauv laravel? Taw qhia. Laravel suav nrog txoj kev yooj yim ntawm noob koj database nrog cov ntaub ntawv xeem siv noob chav kawm. Tag nrho noob cov chav kawm muab khaws cia rau hauv database / noob phau ntawv. Noob Cov chav kawm yuav muaj ib lub npe uas koj xav tau, tab sis tej zaum yuav tsum ua raws li qee qhov kev pom zoo, xws li UsersTableSeeder, thiab lwm yam.

Ib yam li ntawd, koj tuaj yeem nug, koj siv lub seeder li cas?

Yuav Siv Lub Vaj Seeder Li Cas

  1. Kauj Ruam 1 – Xaiv cov noob. Koj yuav tsum tsis txhob ntub cov noob ua ntej koj siv lub vaj seeder.
  2. Kauj Ruam 2 – Xaiv cov noob daim phiaj. Lub vaj seeder xav tau cov noob kom raug, nyob ntawm seb cov qoob loo twg koj xav cog.
  3. Kauj Ruam 3 - Siv Cov Seeder Los Sow Noob.
  4. Kauj Ruam 4 - Siv Seeder los Fertilize qoob loo.

Yuav ua li cas khiav ib tug seeder hauv laravel?

A noob chav kawm tsuas muaj ib txoj hauv kev los ntawm lub neej ntawd: khiav . Txoj kev no yog hu ua thaum db: noob Artisan hais kom ua. Hauv lub khiav txoj kev, koj tuaj yeem ntxig cov ntaub ntawv rau hauv koj lub database txawm li cas los xij koj xav tau. Koj tuaj yeem siv tus tsim cov lus nug los ntxig cov ntaub ntawv los yog koj tuaj yeem siv Eloquent qauv factories.

Pom zoo: