Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SaniSoft Blog:
unbindModel() and paginate() gotcha in CakePHP 1.2
Mar 06, 2008 @ 18:59:00

Tarique Sani has pointed out a little "gotcha" he came across when working in his CakePHP application a while back, specifically with the unbindModel and paginate methods.

A small note to myself regarding a gotcha which I ran into today morning with the built in unbindModel method which lets you disassociate model relations on the fly.

He sets up a situation where his model works correctly in one case but reverts back to the bindings it started with in another. He provides a way around it - an optional parameter that forces the CakePHP framework to treat things correctly.

tagged: cakephp framework unbindmodel paginate

Link:

The Bakery:
An improvement to unbindModel on model side
Dec 14, 2006 @ 13:56:00

The Bakery has a new CakePHP tip posted today showing how to improve the unbindModel handling on the model side of things (versus in the controller as mentioned previously).

The problem with that solution is that it requires you to change the way you define your model relations. [...] Rather try to change your code to suit your needs, and let CakePHP do what it does best: act as a framework.

The technique approaches the associations differently - loaded and called when you make the call to expects() versus just automatically. They include the code to make it all work for an extension to the Model (AppModel), and extension to the AppModel (Title), and finally the TitlesController that shows the deliberate calls to expects to pull in the models.

tagged: improvement unbindmodel model controller expect load improvement unbindmodel model controller expect load

Link:

The Bakery:
An improvement to unbindModel on model side
Dec 14, 2006 @ 13:56:00

The Bakery has a new CakePHP tip posted today showing how to improve the unbindModel handling on the model side of things (versus in the controller as mentioned previously).

The problem with that solution is that it requires you to change the way you define your model relations. [...] Rather try to change your code to suit your needs, and let CakePHP do what it does best: act as a framework.

The technique approaches the associations differently - loaded and called when you make the call to expects() versus just automatically. They include the code to make it all work for an extension to the Model (AppModel), and extension to the AppModel (Title), and finally the TitlesController that shows the deliberate calls to expects to pull in the models.

tagged: improvement unbindmodel model controller expect load improvement unbindmodel model controller expect load

Link:

The Bakery:
Keeping bindModel and unbindModel out of your Controllers
Dec 08, 2006 @ 19:53:15

On the Bakery (the CakePHP site), there's a new entry talking about how to keep bindModel and unbindModel (create/destroy associations) out of your Controller and banishing them back to where they belong.

Here I show you how to add a simple method to your Model classes that allows your controllers to specify binds directly, in a cleaner, more proper way.

They start with a simple modification to the AppModel class before implementing the associations in another class, Title, extending the new and improved AppModel. They follow with with a clean, bindModel-free Controller that sets values and reads from the associated model data.

tagged: cakephp framework bindmodel unbindmodel model controller cakephp framework bindmodel unbindmodel model controller

Link:

The Bakery:
Keeping bindModel and unbindModel out of your Controllers
Dec 08, 2006 @ 19:53:15

On the Bakery (the CakePHP site), there's a new entry talking about how to keep bindModel and unbindModel (create/destroy associations) out of your Controller and banishing them back to where they belong.

Here I show you how to add a simple method to your Model classes that allows your controllers to specify binds directly, in a cleaner, more proper way.

They start with a simple modification to the AppModel class before implementing the associations in another class, Title, extending the new and improved AppModel. They follow with with a clean, bindModel-free Controller that sets values and reads from the associated model data.

tagged: cakephp framework bindmodel unbindmodel model controller cakephp framework bindmodel unbindmodel model controller

Link:


Trending Topics: