Difference between #18 and #19 of
Drills : Search by a HAS_MANY relation in Yii 1.1

Revision #19 has been created by softark on Sep 29, 2018, 11:46:41 PM with the memo:

Changed markup for query results from "code" to "list"
« previous (#18) next (#20) »

Changes

Title unchanged

Drills : Search by a HAS_MANY relation in Yii 1.1

Category unchanged

Tutorials

Yii version unchanged

1.1

Tags unchanged

search,has_many,CActiveRecord

Content changed

[...]
What about this? Seems OK. You will not see the error anymore.

But, alas, you will get the strange output like this:

-    [search word = **foo]
 
   
**
 
-
Author = Andy    - Post = Don't use **foo**    - Post = Use yoo for **foo
 
   
**
 
-
Author = Ben    - Post = **foo** is great    - Post = I love **foo
 
   
**
 
-
Author = Charlie    - Post = What's **foo**? -    [end]

We want to show 5 authors, but the list ends where the count of posts sums up to 5.
[...]
But it still doesn't work. It will show the results like this:

-    [search word = **foo]
 
   
**
 
-
Author = Andy    - Post = Don't use **foo
 
       
**
 
-
Post = Use yoo for **foo    **    - Post = Don't use bar    - Post = Use yar for bar    - Author = Ben    - Post = **foo** is great    - Post = I love **foo**    - Post = I also love bar    - Author = Charlie    - Post = What's **foo**?    - Post = What's bar? -    [end]

It is because LIMIT is not applied to the primary table, but to the virtually constructed table that is the result of joining. It's no use complaining about this behavior, because that's how the query works in RDB.

But we won't give up. Let's try grouping then.
[...]
22 0
27 followers
Viewed: 76 528 times
Version: 1.1
Category: Tutorials
Written by: softark
Last updated by: softark
Created on: Dec 6, 2012
Last updated: 5 years ago
Update Article

Revisions

View all history