Register here!

Forgot password?

ASK NEW QUESTION

Home Page » Active Record » Complex SQL
0 Votes
Vote Con!
Solved!

Complex SQL

ACTIVERECORDsql

What is a good way to incorporate the following complex SQL into a Yii application?

  1. select * from (
  2.    SELECT * FROM (
  3.       SELECT * FROM tbl_extradata ORDER BY field1 DESC) AS s
  4.    GROUP BY user_id) as ss
  5. where filterfield='IN'
select * from (
   SELECT * FROM (
      SELECT * FROM tbl_extradata ORDER BY field1 DESC) AS s
   GROUP BY user_id) as ss 
where filterfield='IN'

Manually or is there a way to use CDbCriteria cleanly?

By mminnie in Active Record · Asked 523 days 15 hours 41 mins ago

Questions: 1 Accepted: 0 ( 0% ) | Reputation: 0

 

Answers (2)

  1. 0 votes
    Accepted

    For complex SQL I highly recommend the use of DAO: http://www.yiiframework.com/doc/guide/1.1/en/database.dao

    By toni · 519 days 18 hours 43 mins ago

    Questions: 0 Accepted: 0 ( 0% ) | Reputation: 0

    • Thanks. That looks perfect. I don't know why that didn't come up in all my searching.

      By mminnie · 519 days 17 hours 22 mins ago

© YiiAnswers.com 2011. All rights reserved.

Switch to our mobile site