Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8547743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:19:58+00:00 2026-06-11T13:19:58+00:00

hi all I’m trying to do two things with a find, the model disputes

  • 0

hi all I’m trying to do two things with a find,
the model disputes belongsTo invoices.

find all invoices where

invoice.receiver_id=account.id

and

dispute.invoice_id=invoice.id

currently the array is returning null when I debug. There should be 2 results in the find statement

here is the code in my disputes controller

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);
  }

This is in the disputes controller, as I want to print out a list about invoices that have disputes.

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 `pra`.`accounts` AS `SenderAccount` ON (`Invoice`.`sender_id` = `SenderAccount`.`id`) LEFT JOIN `pra`.`templates` AS `Template` ON (`Invoice`.`template_id` = `Template`.`id`) WHERE `Invoice`.`id` = 'Dispute.invoice_id' AND `Invoice`.`receiver_id` = 2

EDIT ———————

invoices tables has - id, sender_id, receiver_id, amount, expiry_date, created, paid
disputes table has - id, dispute_date, comment, active

the disputes model looks like this

public $belongsTo = array(
    'Invoice' => array(
            'className' => 'Invoice',
            'foreignKey' => 'invoice_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
            )
        );

public $hasOne = array(
        'Sender' => array(
            'className' => 'Account',
            'foreignKey' =>'sender_id',
            'associationForeignKey'  => 'accounts_id',),
        'Receiver'=> array(
            'className' => 'Account',
            'foreignKey' =>'receiver_id',
            'associationForeignKey'  => 'accounts_id',
            )
            );

disputes has one sender and one receiver as one invoice can have only one dispute.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:19:59+00:00Added an answer on June 11, 2026 at 1:19 pm

    try this code if you are into DisputeController:
    I don’t know if the table name is invoices

     $id = $this->Auth->User('account_id');
    
    $options['joins'] = array(    
        array(
                'table' => 'invoices',
                'alias' => 'i',
                'type' => 'INNER',
                'conditions' => array(            
                    'i.id' => 'invoice_id',  
                        'i.receiver_id' => $id      
                    )    
          ));
    
     $receiver = $this->Dispute->find('all', $options);
    
      $this->set('id',$id);
      $this->set('receiver', $receiver);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All -- I have these two methods in one of my classes: public static
all. We're trying to get some intersect collisions working, but the problem experience is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
All, I am trying to create a table to receive user inputs (UGC). This
All, I'm writing an extensive iPad application with a Core Data based data model.
All, I currently have two projects that are under SourceSafe that I am unable
All I'm trying to do is something fairly simple : Create a class (let's
All- I am trying to get the user's current location than display that on
all, I am trying to multiply a matrix to a vector in OpenGL, but
All, I'm trying to split my MSTest test run into multiple runs because I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.