小编use*_*064的帖子

Cakephp发现返回null

大家好我想用一个发现做两件事,模特争议属于发票.

找到所有发票到哪里

invoice.receiver_id=account.id

dispute.invoice_id=invoice.id

当我调试时,数组返回null.find语句中应该有2个结果

这是我的争议控制器中的代码

public function index_admin(){


    $id = $this->Auth->User('account_id');

    $receiver = $this->Invoice->find('all',array(
    'conditions'=>array("AND"=>array(
    'Invoice.id'=>'Dispute.invoice_id',
    'receiver_id'=>$id))));

        $this->set('id',$id);
        $this->set('receiver', $receiver);
  }
Run Code Online (Sandbox Code Playgroud)

这是在争议控制器中,因为我想打印一份有关有争议的发票的清单.

Query   Error   Affected    Num. rows   Took (ms)
1   SELECT `Invoice`.`id`, `Invoice`.`scheduled`, `Invoice`.`paid`, `Invoice`.`sender_id`, `Invoice`.`receiver_id`, `Invoice`.`template_id`, `Invoice`.`created`, `Invoice`.`expiry_date`, `Invoice`.`total_amount`, `ReceiverAccount`.`id`, `ReceiverAccount`.`street`, `ReceiverAccount`.`city`, `ReceiverAccount`.`postcode`, `ReceiverAccount`.`state`, `ReceiverAccount`.`country`, `ReceiverAccount`.`active`, `ReceiverAccount`.`account_name`, `ReceiverAccount`.`abn`, `SenderAccount`.`id`, `SenderAccount`.`street`, `SenderAccount`.`city`, `SenderAccount`.`postcode`, `SenderAccount`.`state`, `SenderAccount`.`country`, `SenderAccount`.`active`, `SenderAccount`.`account_name`, `SenderAccount`.`abn`, `Template`.`id`, `Template`.`name`, `Template`.`description`, `Template`.`account_id`, `Template`.`active` FROM `pra`.`invoices` AS `Invoice` LEFT JOIN `pra`.`accounts` AS `ReceiverAccount` ON (`Invoice`.`receiver_id` = `ReceiverAccount`.`id`) LEFT JOIN …
Run Code Online (Sandbox Code Playgroud)

sql cakephp

7
推荐指数
1
解决办法
1165
查看次数

标签 统计

cakephp ×1

sql ×1