0

I have two find statements and need the results of one find statement to use in the second find statement however the two methods I have tried to use have come back with errors

here is the first find statement, it lists the sender_id's

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

here is the second find statement, it takes that list of sender_id's and returns the corresponding company_name

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

this returns the right information however returns this error Warning (2): Illegal offset type [APP\Controller\InvoicesController.php, line 185]

so i tried doing it this way

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

and get an undefined index on invoice.

1 Answer 1

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

The key is the field and the value is, well, the value(s).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.