datagenerationbehavior Automatically generate some random data sets for a specified model.

  1. Requirements
  2. Usage

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

  1. Extract the DataGenerationBehavior.php into your components/ folder

  2. Register the behavior on the model where you want to generate demo data :

public function behaviors() {
	return array(
		'DataGenerationBehavior' => array(
		'class' => 'application.components.DataGenerationBehavior',
	)
);
}

  1. Make sure to be in YII_DEBUG mode and call $model->generateDemoData(); somewhere.

  2. 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)
2 0
5 followers
329 downloads
Yii Version: 1.1
License: GPL-3.0
Category: Database
Developed by: thyseus
Created on: Mar 26, 2013
Last updated: 11 years ago

Downloads

show all

Related Extensions