Inheritance in kohana
Posted
by Binaryrespawn
on Stack Overflow
See other posts from Stack Overflow
or by Binaryrespawn
Published on 2010-06-02T14:53:13Z
Indexed on
2010/06/02
15:04 UTC
Read the original article
Hit count: 229
kohana
Hi all, I have recently started to use Kohana and I know inheritance is in infancy stages at the moment. The work around is using a $_has_one annotation on the child class model. In may case i have "page" as the parent of "article". I have something like,
protected $_has_one = array('mypage'=>array('model'=>'page', 'foreign_key'=>'id'));
In my controller, I have an action which queries the database. In this query I am trying to access fields form the parent of "article" which is the "page".
$n->articles=ORM::factory('article')->where('expires','=',0)
->where('articledate','<',date('y-m-d'))
->where('expirydate','>',date('y-m-d'))
->where('mypage->status','=','PUBLISHED')
->order_by('articledate','desc')
->find_all();
The status column resides in the page table and my query is generating an error to the effect of "cannot find status", clearly because it belongs to the parent.
Any ideas ?
© Stack Overflow or respective owner