Create a Customer model class used to collect user input. Here we use Active Record Model, Because we need to save user input into the database.
Here we go.....
We define Customer model class as Active Record model class by extending CActiveRecord. Active Record model class represents a single database table. Here it is "customer" table. Active record instance represents a row in that table. Here it is one row(record) in customer table.
class Customer extends CActiveRecord {
public static function model($className = __CLASS__) {
return parent::model($className);
}
public function tableName() {
return 'customer';
}
}
Normally Active Record class name is database table name. If you want to use different names for table and Active Record class you can override tableName() function as mentioned above.
Here we go.....
We define Customer model class as Active Record model class by extending CActiveRecord. Active Record model class represents a single database table. Here it is "customer" table. Active record instance represents a row in that table. Here it is one row(record) in customer table.
class Customer extends CActiveRecord {
public static function model($className = __CLASS__) {
return parent::model($className);
}
public function tableName() {
return 'customer';
}
}
Normally Active Record class name is database table name. If you want to use different names for table and Active Record class you can override tableName() function as mentioned above.
No comments:
Post a Comment