2009年2月7日星期六

Re: [fw-db] Zend DB and find (strange behaviour)

no, you are using find on RElationModel, that is any subcalls even if the
method is in the super class will be redirected to the
RelationModel::fetchAll. That is standard OO behaviour

On Saturday 07 February 2009 15:30:15 Benjamin Eberlei wrote:
> find() builds a WHERE clause as a string and gives it to fetchAll()
> with the appropriate conditions. Therefore your overwrite
> is false, because $select can also be a string and you don't check for
> that.
>
> On Saturday 07 February 2009 15:25:53 PHPScriptor wrote:
> > My RelationModel:
> >
> > class RelationModel extends Zend_Db_Table_Abstract {
> > protected $_name = 'relations';
> > protected $_primary = array('id');
> >
> > public function fetchAll($select=null) {
> > if(is_null($select))
> > $select = parent::select();
> >
> > $select->setIntegrityCheck(false); => this is the problem
> >
> > $select->from($this->_name)
> > ->joinLeft('common_countries',
> > 'common_countries.id=relations.country_id',
> > array('country)
> > )
> >
> > $results = parent::fetchAll($select);
> > return $results;
> > }
> >
> > My Controller:
> >
> > $model = new RelationModel();
> > $results = $model->find(1);
> >
> > it's returning : "Fatal error: Call to a member function
> > setIntegrityCheck() on a non-object in ..."
> > Why is it going in my 'RelationModel' and calls the function fetchAll?
> > Anyone had the same problem?
> >
> > -----
> > visit my website at http://www.phpscriptor.com/
> > http://www.phpscriptor.com/

--
Benjamin Eberlei
http://www.beberlei.de

没有评论: