Did that. Now when I do :
$db=$this->getAdapter();
$result=$db->find(1);
I get :
Fatal error: Call to undefined method Zend_Db_Adapter_Pdo_Mysql::find()
Lee Saferite wrote:
>
> If I'm not mistaken, you need to call the parent constructor inside your
> POCInstance __construct function.
>
> Something like:
>
> public function __construct()
> {
> parent::__construct();
> }
>
> The reason is that the Zend_Db_Table constructor calls _setup(), which
> populates the per instance adapter that you are trying to get with
> getAdapter(). It looks for a specific adapter being passed in the config
> array and in the absense of one, it uses a reference to the default
> adapter.
>
>
> At least, that's how I read the code. =)
>
>
>
> On 12/7/06, wimg <[EMAIL PROTECTED]> wrote:
>>
>>
>> I've attached the full code :
>> - index.php - bootstrap
>> - IndexController.php
>> - POCInstance.php - the class POCInstance
>>
>>
>>
>>
>> Lee Saferite wrote:
>> >
>> > Matthew,
>> >
>> > In the first message from wimg, it says that
>> > Zend_Db_Table::setDefaultAdapter($db)
>> > is being called.
>> > However, even if that were not the case, you should not be able to get
>> the
>> > reported error, at least as far as I can tell from the code in
>> question.
>> > If the default adapter was never set the it should be throwing an
>> > Exception
>> > since there is no default adapter and one is not being passed in the
>> > constructor.
>> >
>> > Seems to me it would help a lot in troubleshooting if we had the real
>> code
>> > to look at.
>> >
>> > Lee
>> >
>> > On 12/6/06, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
>> >>
>> >> -- 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/
>> >>
>> >
>> >
>> http://www.nabble.com/file/4493/index.php index.php
>> http://www.nabble.com/file/4494/IndexController.php IndexController.php
>> http://www.nabble.com/file/4495/POCInstance.php POCInstance.php
>> --
>> View this message in context:
>> http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7735500
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7739734
Sent from the Zend Framework mailing list archive at Nabble.com.