error on validate()


I’ve the

class AuthItemChild extends CActiveRecord


	public $parent;

	public $child;

	public static function model($className=__CLASS__)


		return parent::model($className);


	public function tableName()


		return 'AuthItemChild';


	public function rules()


		return array(

			array('parent', 'save'),

			array('parent', 'required'),

			array('child', 'save'),

			array('child', 'required'),




do this:

$model = new AuthItemChild;

$model->attributes = array('child' => 'testValue1', 'parent' => 'testValue2');





and get this error:

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'parent' cannot be null

It seems as the Class can’t get the Attributes child and parent.

But if I test this, all seems to be OK:

$x = $model->parent; // $x = testValue2

$x = $model->child; // $x = testValue1

Can anybody say, what is going wrong?

What does

array('parent', 'save'),


array('child', 'save'),



Without that it works, thanks!

Well, I thougt ‘save’ make a security check for possible include Javascript, forbidden html and so on.

This Option I’ve seen any where and I was sure

array('parent', 'save'),

is it.

Hmm…looks like I have to read more Docu.

Yes, there exists an option ‘save’.

So leave blank save option is not the solution.

abstract class CValidator extends CComponent



	 * @var array list of built-in validators (name=>class)


	public static $builtInValidators=array(




















Is saFe, not saVe.

CSafeValidator actually does not do any validation, it just make safe the attribute.

It is unuseful if you have already other validators.

100% right :)

Yeah! Right! sa[size="4"]f[/size]e, not sa[size="4"]v[/size]e.

Ok, safe validation is a child of all other validations.