News Feed
Sections




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

Blog.szajbe.pl:
Not so obvious behavior of $uses in CakePHP
July 09, 2008 @ 12:02:41

In this new post to the blog.szajbe.pl site a dilemma is presented - CakePHP models are not working they way one would think they should.

In CakePHP you declare what models you're going to use in a controller by defining $uses variable. You can also define it in AppController to have a certain set of models available in every controller. However be careful when doing it because you may put yourself in an unexpected situation as I did recently.

As soon as he made his script include a 'User' model in every quest, his logins stopped working. His script errored with a "Database table sessions for model Session was not found" message and refused to work. Digging deeper, he found that CakePHP merges an AppController's $uses value with the SessionControler's values. One overrides the other and your 'User' gets lost in the shuffle.

Do you have a rational explanation for such behavior? I have none. It's very unintuitive for me.
0 comments voice your opinion now!
cakephp model behavior user login appcontroller sessioncontroller merge uses


blog comments powered by Disqus

Similar Posts

Job Posting: Eqqus.com Seeks User Interface Engineer (Mountain View, CA)

The Show: Special Guest: Mozilla's Laura Thomson

Chris Hartjes' Blog: The Devilís In The Details (or, Handling Sequences in Postgres in CakePHP)

Jim Plush's Blog: I'm Officially a Baker with CakePHP

Matthew Weier O'Phinney: RESTful APIs with ZF2, Part 1


Community Events

Don't see your event here?
Let us know!


voicesoftheelephpant interview introduction extension php7 language version library laravel laravel5 opinion release framework unittest community list podcast example series api

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework