Revision #18 has been created by softark on Sep 29, 2018, 11:27:07 PM with the memo:
Fixed a markup
« previous (#17) next (#19) »
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.[...]