Can someone explain it to me how to create DAO object in a model?
It’s only explained how to get the results, but not how to populate the attributes.
This is what I wrote, but I’m sure this is not the right way.
This is a model:
private $_cmdSelect;
public $user;
sql = 'SELECT * FROM periods WHERE user=:user LIMIT 1';
$this->_cmdSelect = Yii::app()->db->createCommand($sql);
$this->_cmdSelect->bindValue(':user', $this->user, PDO::PARAM_STR);
$this->_attributes = $this->_cmdSelect->queryRow();
Written on this way generally works. The problem is when I try to change the attribute value with this…
$this->someattr = something
…I get a fatal error “Call to a member function bindValue() on a non-object”. It works only in one model, but I don’t know why. By examining the model in a view file I noticed that I’m missing _schema:private value. I just don’t know how it gets populated…
Can somebody help me?
Thanks in advance!