Sorry im new in cakePHP. i use cakePHP 2.2. I have two table, Books and Transactions.
Table : Books
id
title
author
Table : Transactions
id
book_id
status
borrow_date
In table transaction list all transaction of the book.
My question, how to get status of max transaction id?
I try use this
options['joins'] = array( array( 'table' => 'transactions', 'alias' => 'Transaction', 'type' => 'RIGHT OUTER', 'fields' => array('MAX(Transaction.id)', '*'), 'conditions' => array( 'Catalogue.id = Transaction.catalogue_id', //'Transaction.user_id' => $userId ), 'order' => array('Transaction.id' => 'desc'), ) ); $this->set('Book', $this->Book->find('all',$options));
at view:
$Book['Transaction']['status'];
But it shows an error:
Notice (8): Undefined index: Transaction [APP\View\Catalogues\user_katalog.ctp, line 32]