-- wimg <[EMAIL PROTECTED]> wrote
(on Wednesday, 06 December 2006, 07:29 AM -0800):
> It returns NULL.
>
> I'm completely puzzled by this. I've used framework 0.1.5 and it worked
> fine, but 0.2.0 just fails on this.
>
> When I store the $db element in the registry, then do this :
> $db=Zend::registry('db');
> $select=$db->select();
> $select->from('Article','*')
> ->where('Artcile_id',$id);
> $result=$db->fetchOne($select->__toString());
> print_r($result);
>
> The print_r returns '1', nothing more.
Did you call Zend_Db_Table::setDefaultAdapter()? This has to be done for
your various table objects to have access to the adapter:
// in your bootstrap...
$db = Zend::registry('db');
Zend_Db_Table::setDefaultAdapter($db);
Then, any Table object created will automagically have access to the
database adapter.
> Dinh wrote:
> >
> > You may be need to check if $this->getAdapter() returns an expected
> > object. var_dump() should be useful here.
> >
> > Dinh
> >
> > On 12/6/06, wimg <[EMAIL PROTECTED]> wrote:
> >>
> >> I've been setting up an app using Zend Framework 0.2.0.
> >> I have a simple index.php, which :
> >> - includes Zend.php
> >> - sets autoloading for classes
> >> - connects to MySQL database using PDO_MYSQL
> >> - Does "Zend_Db_Table::setDefaultAdapter($db);"
> >>
> >> The IndexAction on the IndexController contains :
> >> $inArticle = new Article();
> >> $inArticle->getArticle(1);
> >>
> >> The Article.php in the models contains :
> >>
> >> class Article extends Zend_Db_Table
> >> {
> >> protected Article_id;
> >> protected Article_name;
> >>
> >> public function getArticle($id)
> >> {
> >> $db=$this->getAdapter();
> >> $where=$db->quoteInto('Article_id=?',$id);
> >> $row=$db->fetchOne($where);
> >> $this->Article_name=$row->Article_name;
> >> }
> >> }
> >>
> >>
> >> When I run this example, I get :
> >> Fatal error: Call to a member function quoteInto() on a non-object in ...
> >>
> >> Any idea what might be wrong here ? I've also tried it with 'find', but
> >> that
> >> gives the same error.
> >>
> >> I am extending Zend_Db_Table, so I thought I should be able to access the
> >> functions quoteInto and find ?
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7720515
> >> Sent from the Zend Framework mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Nobody in nowhere
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7721493
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/