When I use pocinstanceId, I get :
Notice: Undefined index: POCInstance_id in
/var/www/html/poc/library/Zend/Db/Table/Row.php on line 96



Matthew Weier O wrote:
> 
> 
> So, try print $result->pocinstanceId, and you should be good to go.
> 
>> a print_r($result) gives me :
>> Zend_Db_Table_Row Object
>> (
>>     [_data:protected] => Array
>>         (
>>             [pocinstance_id] => 1
>>             [template_id] => 0
>>             [pocinstance_name] => Test instance
>>             [pocinstance_description] => This is a test instance
>>             [pocinstance_locked_user_id] => 0
>>             [pocinstance_locked_datetime] => 0000-00-00 00:00:00
>>             [pocinstance_hostname] => test
>>         )
>> 
>> 
>> 
>> 
>> 
>> Matthew Weier O wrote:
>> > 
>> > -- wimg <[EMAIL PROTECTED]> wrote
>> > (on Thursday, 07 December 2006, 06:04 AM -0800):
>> >> 
>> >> 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()
>> > 
>> > You're calling the method on the wrong object. find() is only available
>> > via a Zend_Db_Table object, which I'm assuming $this is in your snippet
>> > above. Try this:
>> > 
>> >     $result = $this->find(1);
>> > 
>> > Within your Zend_Db_Table objects, you shouldn't need to access the
>> > adapter unless you need to do specialized queries or want to return
>> > result sets other than Zend_Db_Table_Rows and Zend_Db_Table_Rowsets.
>> > 
>> > In the former case, which is how you started the thread (a question
>> > about quoteInto()), you can then do things like:
>> > 
>> >     $where = $this->getAdapter()->quoteInto('value = ?', $value);
>> > 
>> >> 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 ?
>> > 
>> > -- 
>> > Matthew Weier O'Phinney
>> > PHP Developer            | [EMAIL PROTECTED]
>> > Zend - The PHP Company   | http://www.zend.com/
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7740447
>> 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/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/inheritance-not-working---tf2768458s16154.html#a7740978
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to