Model News is associated with the Files one to one. Trying to do a relational query:
$model=News::model()->with('files')->findByPk($_GET['id']); If I have an entry in the files table corresponding to $_GET['id'] , then everything is ok. If there is no file, then throws an error:
Fatal error: Call to a member function isAttributeRequired() on a non-object in C:\...\yii\framework\web\helpers\CHtml.php on line 1514 Tried to use lazy loading - the same.
It is exactly necessary for me that, in the presence of a file, it would be selected along with the news, and in its absence, only the news would be selected.
FinByPk method:
public function findByPk($pk,$condition='',$params=array()) { Yii::trace(get_class($this).'.findByPk()','system.db.ar.CActiveRecord'); $prefix=$this->getTableAlias(true).'.'; $criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params,$prefix); return $this->query($criteria); }
public function findByPk($pk,$condition='',$params=array()) { Yii::trace(get_class($this).'.findByPk()','system.db.ar.CActiveRecord'); $prefix=$this->getTableAlias(true).'.'; $criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params,$prefix); return $this->query($criteria); }public function findByPk($pk,$condition='',$params=array()) { Yii::trace(get_class($this).'.findByPk()','system.db.ar.CActiveRecord'); $prefix=$this->getTableAlias(true).'.'; $criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params,$prefix); return $this->query($criteria); }public function findByPk($pk,$condition='',$params=array()) { Yii::trace(get_class($this).'.findByPk()','system.db.ar.CActiveRecord'); $prefix=$this->getTableAlias(true).'.'; $criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params,$prefix); return $this->query($criteria); }. Only I do not know what exactly is not working correctly - Jeque