The issue is that dynamic binding is "reset" by default after each call to Model::findXXX, and paginate() generates 2 such calls, one to Model::findCount and one to Model::findAll (unless the model has methods paginateCount() and paginate(), in which case they are called instead). So if you call (un)bindModel with reset=true [default], cake restores the association after the findCount(), so it doesn't persist to the findAll().
For projects where I do a lot of dynamic binding, I set up my AppModel up to handle association saving manually, a bit like this : http://pastebin.com/f5dd5e855 Then you do this: // Save associations $this->User->pushAssociations(); // bindModel now defaults to reset=false, so cake doesn't attempt to restore the assocs $this->User->bindModel(array('hasOne' => array('Something'))); // If the model is already loaded and setup then you can change attributes directly $this->User->hasMany['Post']['conditions'] = array('blah' => 'woof'); // Now call paginate $data = $this->paginate('User'); // Now restore associations manually $this->User->popAssociations(); It takes a bit more work, but it works for me when I need it too. Just make 100% sure you balance push and pop, and it works fine. On Dec 5, 5:23 pm, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > It's in spanish, but look at the paginate() and paginateCount() > implementation, they should be on your model so you can override > Controller::paginate() auto-calls to find('count') and find('all') so it > instead calls your implementation, where you can do your bindModel() / > unbindModel() : > > http://groups.google.com/group/CakePHP-es/browse_thread/thread/af2c33... > b20/c07817f02457b52a#c07817f02457b52a > > -MI > > --------------------------------------------------------------------------- > > Remember, smart coders answer ten questions for every question they ask. > So be smart, be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > _____ > > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre > de Baz > Enviado el: MiƩrcoles, 05 de Diciembre de 2007 02:04 p.m. > Para: cake-php@googlegroups.com > Asunto: unbindModel and this->paginate > > Is there a simple way to get unbindModel and bindModel to work with > $this->paginate? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---