View Single Post
  #1 (permalink)  
Old 12-20-2007, 03:23 AM
conradwt conradwt is offline
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.
Reply With Quote