Undefined property: Zend_Db_Table_Select

R7AF
R7AF used Ask the Experts™
on
When running this code, I get the following error:

Notice: Undefined property: Zend_Db_Table_Select::$price in...

The generated query $select works: SELECT "books".* FROM "books" WHERE ( ac_id = 1234 ) ORDER BY "price" ASC

What am I doing wrong here?
detail.phtml:
<?php echo $this->book->price;?>
 
Books.php:
<?php
class Books extends Zend_Db_Table_Abstract 
{
	protected $_name = 'books';
	
	public function getMinimumPrice($id)
	{
		$where = "ac_id = " . $id . " ";
		$order = "price";
		$count = 1; 
		$select = $this->select()->where($where)->order($order, $count);
		echo $select;
		return $select;
	}
}
?>
 
AcController.php: 
<?php
class AcController extends Zend_Controller_Action
{	
	public function detailAction()
	{
		$id = (int) $this->_request->getParam('id');
		
		$view = new Books();
		$row = $view->getMinimumPrice($id);
		$this->view->book = $row;
	}
}
?>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What line is the error occurring on? On the $select = .... line or on the line where you echo the price?
Commented:
Also, what is the output if you add:
print_r($row);
after the $row = $view->getMinimum..... line?
Top Expert 2007

Author

Commented:
This line results in the error:

<?php echo $this->book->price;?>
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Top Expert 2007

Author

Commented:
Thanks for the reply. Below you can see the print_r($row) results:
Zend_Db_Table_Select Object
(
    [_info:protected] => Array
        (
            [schema] => 
            [name] => books
            [cols] => Array
                (
                    [0] => id
                    [6] => price
                )
 
            [primary] => Array
                (
                    [1] => id
                )
 
            [metadata] => Array
                (
                    [price] => Array
                        (
                            [SCHEMA_NAME] => public
                            [TABLE_NAME] => books
                            [COLUMN_NAME] => price
                            [COLUMN_POSITION] => 7
                            [DATA_TYPE] => float8
                            [DEFAULT] => 
                            [NULLABLE] => 1
                            [LENGTH] => 8
                            [SCALE] => 
                            [PRECISION] => 
                            [UNSIGNED] => 
                            [PRIMARY] => 
                            [PRIMARY_POSITION] => 
                            [IDENTITY] => 
                        )
                )
 
            [rowClass] => Zend_Db_Table_Row
            [rowsetClass] => Zend_Db_Table_Rowset
            [referenceMap] => Array
                (
                )
 
            [dependentTables] => Array
                (
                )
 
            [sequence] => books_id_seq
        )
 
    [_integrityCheck:protected] => 1
    [_table:protected] => Books Object
        (
            [_name:protected] => books
          
            [_schema:protected] => 
            [_cols:protected] => Array
                (
                    [0] => id
                    [6] => price
                )
 
            [_primary:protected] => Array
                (
                    [1] => id
                )
 
            [_identity:protected] => 1
            [_sequence:protected] => books_id_seq
            [_metadata:protected] => Array
                (
                    [id] => Array
                        (
                            [SCHEMA_NAME] => public
                            [TABLE_NAME] => books
                            [COLUMN_NAME] => id
                            [COLUMN_POSITION] => 1
                            [DATA_TYPE] => int4
                            [DEFAULT] => nextval('books_id_seq'::regclass)
                            [NULLABLE] => 
                            [LENGTH] => 4
                            [SCALE] => 
                            [PRECISION] => 
                            [UNSIGNED] => 
                            [PRIMARY] => 1
                            [PRIMARY_POSITION] => 1
                            [IDENTITY] => 1
                        )
 
                    [price] => Array
                        (
                            [SCHEMA_NAME] => public
                            [TABLE_NAME] => books
                            [COLUMN_NAME] => price
                            [COLUMN_POSITION] => 7
                            [DATA_TYPE] => float8
                            [DEFAULT] => 
                            [NULLABLE] => 1
                            [LENGTH] => 8
                            [SCALE] => 
                            [PRECISION] => 
                            [UNSIGNED] => 
                            [PRIMARY] => 
                            [PRIMARY_POSITION] => 
                            [IDENTITY] => 
                        )
 
                )
 
        )
)

Open in new window

Commented:
Okay, what's the context around the problem line:
<?php echo $this->book->price;?>

1. What's the code before and after it?
2. Is this line inside a class? (the $this variable usually refers to the instance of a class from within that class)
Top Expert 2007

Author

Commented:
Found the problem! The print_r was a good suggestion. I forgot to add a fetchRow.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial