R7AF
asked on
Undefined property: Zend_Db_Table_Select
When running this code, I get the following error:
Notice: Undefined property: Zend_Db_Table_Select::$pri ce in...
The generated query $select works: SELECT "books".* FROM "books" WHERE ( ac_id = 1234 ) ORDER BY "price" ASC
What am I doing wrong here?
Notice: Undefined property: Zend_Db_Table_Select::$pri
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;
}
}
?>
What line is the error occurring on? On the $select = .... line or on the line where you echo the price?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This line results in the error:
<?php echo $this->book->price;?>
<?php echo $this->book->price;?>
ASKER
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] =>
)
)
)
)
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)
<?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)
ASKER
Found the problem! The print_r was a good suggestion. I forgot to add a fetchRow.