I need to Find last matched model using findByAttributes ... Help me

I need to Find last matched model using findByAttributes … Help me

‘limit’=>1? However, you should apply some kind of sorting. Otherwise you might find, that there is no real ‘last’ data item in a relational database B)

ok that i knw… thank u very much

findByAttributes already return only one record!

You can always use order parameter in your findByAttributes condition.

Sheesh. I actually got findByAttributes() and findAllByAttributes() mixed up. Terribly sorry.

yeah thats it… i dnt get my actual need… findAllByAttributes with limit will work

FindByAttributes is actually same as findAllByAttributes, with ‘limit’=>‘1’ parameter, so only real difference is that findAllByAttributes return array of Ars, while FindByAttributes return AR.

but i need to last matching table entry if there are more than one matches…FindByAttributes only finds the first matching model… rite?

You’d have to choose an order that would lead to the “last” table entry to come out first in the result set. Something like ‘order’=>‘id DESC’.

yes thats my need… i hv to find last table entry…‘order’=>‘id DESC’ is this possible?

success…array(‘order’=>‘id DESC’) worked… Thank u Da:Sourcerer …

Glad we could help :)