Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-20-2007, 03:23 AM
Member
 
Join Date: Nov 2007
Posts: 33
Question Cannot access id field with model?

Hi, I have a model where I'm trying to access the 'id' field. For example, I have the following code:

PHP Code:
<?php

class Animal extends Zend_Db_Table {
    
      protected 
$_name 'animals';

      public function 
previousAnimal() {

         
$animal = new Animal();
       
$where $animal->getAdapter()->quoteInto'id > ?'$this->id );  //  Error on:  $this->id
         
$orderBy 'id DESC';
         
$previousAnimal $animal->fetchAll$where$orderBy);

       return 
$previousAnimal;    
 
      }


      public function 
nextAnimal() {

      
$animal = new Animal();
      
$where $animal->getAdapter()->quoteInto'id < ?'$this->id ); // Error on:  $this->id
      
$orderBy 'id ASC';
      
$nextAnimal $animal->fetchAll$where$orderBy);

      return 
$nextAnimal;

      }

}

?>
At this time, I'm getting the following message:

Undefined property Animal::$id

How does one define the properties of a model?

Thanks in advance,

-Conrad

Last edited by conradwt : 12-20-2007 at 07:07 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-26-2007, 09:22 PM
Junior Member
 
Join Date: Oct 2007
Posts: 16
Default

In this case Animal is a table class, and therefore it doesn't have any properties.
However, you can fetch rows from it and access their properties respectively.
$this->id doesn't make sense to me. What exactly are you trying to achieve?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:58 PM.