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 7790041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:28:07+00:00 2026-06-01T21:28:07+00:00

I am trying to make a condition that the client ID must match the

  • 0

I am trying to make a condition that the client ID must match the client ID and a region field in the locations table must match the region attached to the location id that is associated with the users location.

So I have 3 tables. The current table(t1), the table relation1 refers to (t2), and the table that t2 refers to in relation2 (we will call this t3).


    $this->getDbCriteria()->mergeWith(array(
        'with' => $rel,
        'condition'=>'relation1.client_id=:client_id AND
                      relation1.relation2.region=:region',
        'params'=>array(':client_id'=>$client_id, ':region'=>$region),
    ));

return $this;

Relation1 is the relation in the table once removed from this one. The table that relation1 refers to has a relation called relation2 that gets me to where I need to retrieve the region value.

If I remove the second condition and parameter it works, so I know relation1 is working, and relation2 also works in other contexts. Here they are if would like to see them.


    public function relations()
    {
        return array(
            'relation1' => array(self::BELONGS_TO, 't2', 't2_id'),
        );
    }

and


    public function relations()
    {
        return array(
            'relation2' => array(self::BELONGS_TO, 't3', 't3_id'),
             );
    } 

I really feel like this should work. Any help?

  • 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-01T21:28:08+00:00Added an answer on June 1, 2026 at 9:28 pm

    I got the answer from another site. If you are interested, the solution is:

    
        $this->getDbCriteria()->mergeWith(array(
                'with' => array(
                    'relation1' => array(
                           'condition' => 'relation1.column = :column_id', 
                           'params' => array(':column_id'=>$column_id)),
                    'relation1.relation2' => array(
                           'condition' => 'relation2.column2 = :column2', 
                           'params' => array(':column2'=>$column2))
                ),
            ));
        return $this;
    
    

    Thanks for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an if condition that checks a couple of things using
Trying to make a custom :confirm message for a rails form that returns data
Trying to make a toggle button that hides/shows the right window/pane. Here is a
I am trying to insert a row into a MySQL table, with the condition
I am trying to make a simple client-server chat program. On the client side
I am trying to make select look like span based on some condition. i
I am trying to make a style that only gets applied if the parent
I'm trying to make a select that calculates affiliate payouts. my approach is pretty
Alright so here is the deal. I am trying to make a application that's
We are trying to build a SQL query builder that would allow users to

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.