I have the following code, which select product from table "products" based on the id.
public function p_details(){
$productIdNum = $this->params['detailID'];
//$this->Product->read(null, $productIdNum);
if(Validation::naturalNumber($productIdNum) == true){
$itemById = $this->Product->find('all', array('conditions' =>
array('Product.id' => $productIdNum)));
if(count($itemById) > 0){
$this->set('itemDetails', $itemById['Product']['id']);
}
}
}
But when I try to print the variable "$itemDetails" in the view,
like <?php echo $itemDetails['Product']['name']; ?>
it's giving me this error:
Undefined index: Product. If I change it to this
like <?php echo $itemDetails['name']; ?>
It's still give me the same error: Undefined index: name.
I can't get to figure this out.