【问题标题】:cakephp array's and find statementcakephp 数组和 find 语句
【发布时间】:2012-08-15 07:13:37
【问题描述】:

我有两个 find 语句,需要一个 find 语句的结果在第二个 find 语句中使用,但是我尝试使用的两种方法返回错误

这里是第一个 find 语句,它列出了 sender_id 的

$sender=$this->Invoice->Find('list', array('fields'=>('sender_id')));

这是第二个 find 语句,它采用 sender_id 的列表并返回相应的 company_name

$senderName=$this->Account->Find('all', array(
        'conditions' => array(
        $sender=>'account.id')));

这会返回正确的信息,但会返回此错误Warning (2): Illegal offset type [APP\Controller\InvoicesController.php, line 185]

所以我试着这样做

$senderName=$this->Account->Find('all', array(
        'conditions' => array(
        'id'=>$sender['Invoice']['sender_id'])));

并在发票上获得未定义的索引。

【问题讨论】:

    标签: sql cakephp find


    【解决方案1】:
    $senderName=$this->Account->Find('all', array(
            'conditions' => array(
                'Account.id' => array_values($sender),
            ),
    ));
    

    键是字段,值是值。

    【讨论】:

      猜你喜欢
      • 2013-03-31
      • 2015-01-10
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多