Skip to content

Commit

Permalink
Dev: review primaryKey and add some rules in Answers model
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Dec 22, 2012
1 parent 97f0bce commit 88dac0d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion application/models/Answers.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function tableName()
*/
public function primaryKey()
{
return array('qid', 'code');
return array('qid', 'code','language','scale_id');
}

/**
Expand All @@ -68,6 +68,23 @@ public function relations()
);
}

/**
* Returns this model's validation rules
*
*/
public function rules()
{
return array(
array('qid','numerical', 'integerOnly'=>true),
array('code','length', 'min' => 1, 'max'=>5),
array('answer','LSYii_Validators'),
array('sortorder','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('assessment_value','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('language','length', 'min' => 2, 'max'=>20),// in array languages ?
array('scale_id','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
);
}

function getAnswers($qid)
{
return Yii::app()->db->createCommand()
Expand Down

0 comments on commit 88dac0d

Please sign in to comment.