我试图让我的 index() 函数仅显示属于该个人登录用户的 ExpenseClaims。
这是功能:
public function index() {
$this->ExpenseClaim->recursive = 0;
$currentUsersClaims = $this->ExpenseClaim->find('all', array('conditions' => array('ExpenseClaim.user_id ==' => $this->Auth->user('id'))));
$this->set('currentUsersClaims', $this->paginate());
}
这是我得到的错误:
数据库错误
错误:SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '== 3' 附近使用正确的语法
SQL Query: SELECT `ExpenseClaim`.`id`, `ExpenseClaim`.`user_id`, `ExpenseClaim`.`claim_status_id`, `ExpenseClaim`.`created`, `ExpenseClaim`.`modified`, `ExpenseClaim`.`approved`, `ExpenseClaim`.`approved_by`, `ExpenseClaim`.`date_submitted`, `User`.`id`, `User`.`username`, `User`.`password`, `User`.`group_id`, `User`.`name`, `User`.`address`, `User`.`department_id`, `User`.`mileage_rate`, `User`.`created`, `User`.`modified`, `ClaimStatus`.`id`, `ClaimStatus`.`name`, `ClaimStatus`.`created`, `ClaimStatus`.`modified` FROM `expenses`.`expense_claims` AS `ExpenseClaim` LEFT JOIN `expenses`.`users` AS `User` ON (`ExpenseClaim`.`user_id` = `User`.`id`) LEFT JOIN `expenses`.`claim_statuses` AS `ClaimStatus` ON (`ExpenseClaim`.`claim_status_id` = `ClaimStatus`.`id`) WHERE `ExpenseClaim`.`user_id` == 3
请原谅我,因为我可能遗漏了一些明显的东西,但我对蛋糕很陌生。