I have a model like bellow:
class Book extends ActiveRecord
{
{ public function getDomain()
{
return $this->hasOne(Domain::className(), ['ID' => 'domainID']);
}
public function getOwnerPerson()
{
return $this->$this->hasOne(Person::className(), ['ID' => 'ownerPersonID']);
}
public function getCreatorUser()
{
return $this->$this->hasOne(User::className(), ['ID' => 'creatorUserID']);
}
public function getUpdaterUser()
{
return $this->$this->hasOne(User::className(), ['ID' => 'updaterUserID']);
}
}
I've created an object from Book model by follow:
$model=Book::find()->all();
when I use $model->domain
, every thing is ok, but when I use $model->ownerPerson
, it throws an error:
Object of class backend\models\Book could not be converted to string
what is the problem?