Strange issue with ActiveRecord limit & offset

Hi everybody.

I’m expierincing strange issue atm.

I have a DB query through relational AR - joining 3 tables to basic table and 5 more tables in chain.

It works, unless I add $criteria->limit or $criteria->offset (or both). When I do it - table chain failing to add to query.

I’m stuck. Help me somebody :)

Have you tried to execute sql expression outside Yii?

Limit and offeset work at root level of query.

Problem is that when I add limit and offeset - AR don’t join some table I need and asked to join, and that are joinning perfectly without L&O.

If i don’t set L&O - anything works fine.

Have you tried to compare sql with and without L&O in firebug? So you can see complete sql.

OK, I found out what happens - one of relations in chain is of HAS_MANY type, so query splits into two queries and bacause one of conditions is adressed to second query, but trying to execute with second one - my code fails.

Thank you anyway :)

Post your code that fails.

I’ve allready figured out what happens. I’m not sure what to do with it, but at least, I have a light in the end of a tonnel now :)