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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:48:49+00:00 2026-06-11T20:48:49+00:00

How to convert mysql query to yii.? I have 3 table user_header customers customer_ratings

  • 0

How to convert mysql query to yii.?

I have 3 table

  1. user_header
  2. customers
  3. customer_ratings

and this is my sql query

SELECT t.email 
FROM   otz_user_header t 
       JOIN otz_customers r 
         ON t.user_id = r.customer_user_id 
       JOIN otz_customer_ratings cr 
         ON cr.customer_user_id = r.customer_user_id 
WHERE  r.rate_auto_approve = 0 
       AND r.rate_email_time IS NOT NULL 
       AND r.total_rating_count IS NOT NULL 
       AND cr.rating_date < Curdate() 
       AND cr.rating_date > Date_sub(Curdate(), INTERVAL 7 day) 

How to convert this query to yii ?

Thanks in advance.

  • 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-11T20:48:50+00:00Added an answer on June 11, 2026 at 8:48 pm

    “itachi” answer’s right, but if you are looking for in activerecord way…

    model: UserHeader

    relations:

    'activeCustomers' => array(
         self::HAS_MANY, 
         'Customer', 
         'customer_user_id', 
         'condition' => 'activeCustomers.rate_auto_approve=0 
                      AND activeCustomers.rate_email_time IS NOT NULL 
                      AND activeCustomers.total_rating_count IS NOT NULL'
    ),
    

    model: Customer

    relations:

    'lastWeekRatings' => array(
         self::HAS_MANY, 
         'CustomerRating', 
         'customer_user_id', 
         'condition' => 'lastWeekRatings.rating_date < CURDATE() 
            AND lastWeekRatings.rating_date > DATE_SUB( CURDATE(), INTERVAL 7 DAY )'
    ),
    

    and the below code returns the MODEL objects as same as your query. ( I haven’t tested it )

    $useremails = UserHeader::model()
         ->with('activeCustomers', 'activeCustomers.lastWeekRatings')
         ->findAll(array(
               'select' => 't.email'
          ));
    print_r($useremails);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySql query like this: select AK.*, max(AA.activityDate) from AssessmentKey AK join
I've got the following MySQL query: <?php $sql = SELECT * FROM my_table; $result
I have a MySQL query: SELECT * FROM t1 WHERE ABS(TIMESTAMPDIFF(MINUTE, ts, (SELECT ts
I am running this mysql query: $result = mysql_query(SELECT * FROM userdetails WHERE userid=
Im trying to figure out the best way to convert this mysql query SELECT
I am trying to convert a mySQL query into a JSON object. This works:
How can I convert a database from MySQL to MS SQL Server 2005?
I have a question about converting charset from inside mysql query. I have a
I have a MySQL query I'm running from C#. I use the MySqlDataAdapter to
I am trying to convert this MSSQL QUERY to MYSQL Query looks like this

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.