Reputation: 18346
I have these codes but save() method doesn't work. What is the problem?
public function rules()
{
return array(
array('name', 'required'),
array('name site_id', 'unique'),
array('status, site_id', 'numerical', 'integerOnly'=>true),
array('name, author', 'length', 'max'=>50),
array('version', 'length', 'max'=>10),
array('config_content', 'safe'),
array('id, name, author, version, status, config_content, site_id', 'safe', 'on'=>'search'),
);
}
and
$new_row = new Module;
$new_row->name = 'test';
$new_row->config_content = 'asasfdfd';
$new_row->site_id = 2;
$new_row->status = 0;
if($new_row->save())
echo 'Yes!';
else
echo 'No!';
Upvotes: 1
Views: 293
Reputation: 31
Hi from what I can see the most likely cause will be because there is a "," missing in the following rule
array('name site_id', 'unique'),
should be
array('name, site_id', 'unique'),
Upvotes: 3