Following this post. I have a Users model for AUTH table. Table contains DEL column (among others, of course).
For many reasons (explained in above mentioned post) I decided to not use CActiveRecord directly. As in mentioned post, I wrote my own search() function in the model, containing pure SQL, and I use dataset returned by that function to populate my model.
It works this way in update scenario and it works fine.
For create scenario, I use following code:
$model = new Users('create');
if (isset($_POST['Users']))
{
$model->attributes = $_POST['Users'];
if($model->validate())
{
$saveResult = $model->save(FALSE);
if($saveResult) $this->redirect(array('index'));
}
}
Insertion of a new record, using above code fails, halted by a trigger set on database side, which claims that DEL attribute is null.
To make myself 100% sure, I placed additional code $model->DEL = 0 just above $model->save(FALSE); and I printed out this value on screen. Everything is fine, up to line preceeding [i]save/i model DEL value is set (to zero) and gets nulled somewhere inside save(). I tested this approach with many test cases, providing different, non-zero values as good as other types (i.e. zero as string). All for nothing. Trigger still claims that DEL is null.
I’ve placed PL/SQL function for raising user errors inside trigger and printed out DEL value passed in INSERT query, as good as value of other attributes. Other attributes are set, DEL is null (empty).
Though this doesn’t seems to be related, I’ve put DEL into rules() and into search() SQL. Even though validation is fine and DEL is passed (set) until save() and even though I don’t use search() in creation of a new record (only in updated of existing one and in list of records).
All for nothing. I don’t know, what else I could check?
So, here is the question. Basing on what CActiveRecord builds a list of parameters passed (binded) to INSERT query used in create scenario? Or what else might be causing that this particular column (attribute) is not passed at all or is being nulled before passing?