This Behavior lets you automatically generate some random data into your database. A random number will be generated for int fields. String fields will be filled with lorem ipsum Text.
Requirements ¶
Developed with Yii 1.1.13. Should work with any 1.1 Version of Yii.
Usage ¶
Extract the DataGenerationBehavior.php into your components/ folder
Register the behavior on the model where you want to generate demo data :
public function behaviors() {
return array(
'DataGenerationBehavior' => array(
'class' => 'application.components.DataGenerationBehavior',
)
);
}
Make sure to be in YII_DEBUG mode and call $model->generateDemoData(); somewhere.
You can configure 'count', 'intMin', 'intMax' or the 'lorem' attribute.
count: number of data sets to be generated, default 10 intMin: minimal number generated for int fields, default 0 maxMin: minimal number generated for int fields, default 1000 lorem: the text generated, default is the lorem ipsum default text.
TODO:
- At the moment we do not obey relations! Would be cool if a random number would be generated only for valid related objects! (for example, a column user_id that links to a specified user would generate a random number between all available users)
Repo?
Is it on github?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.