미안 해요 cakePHP에 새롭게 추가되었습니다. 나는 cakePHP 2.2를 사용한다. 책과 거래라는 두 개의 테이블이 있습니다.CakePHP : 최대 값을 가진 테이블에 가입
표 : 책
id
title
author
테이블 : 트랜잭션 테이블 트랜잭션 목록에서
id
book_id
status
borrow_date
책의 모든 거래.
제 질문은 최대 트랜잭션 ID의 상태를 얻는 방법입니다.
나는이
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));
보기에서 사용하려고 :
$Book['Transaction']['status'];
그러나 오류 보여줍니다
Notice (8): Undefined index: Transaction [APP\View\Catalogues\user_katalog.ctp, line 32]
는 u는 나에게 몇 가지 예제를 줄 수 있습니까? 정의되지 않은 인덱스 : 트랜잭션 [APP \보기 \ 카탈로그 \의 user_katalog.ctp, 라인 32] 내가 사용 –