check out Miles' approach
he uses it in his forum plugin:
http://milesj.me/resources/script/forum-plugin
On 28 Mrz., 08:00, cricket <zijn.digi...@gmail.com> wrote:
> On Mon, Mar 28, 2011 at 12:54 AM, Krissy Masters
>
>
>
>
>
>
>
>
>
> <naked.cake.ba...@gmail.com> wrote:
> > Why is the Session data not available in the Model?
> > Why is it breaking MVC?
> > I do not understand since all data comes from the database basically and if
> > I am saving my session data to the db why would grabbing that data in the
> > model be bad?
>
> > I found Miles J snip for the app_model which I plan to use to get session
> > data since it makes more sense to grab user.id from the session directly in
> > the model rather than grab it in controller only to pass it to the model in
> > the controller function to be used in the model function.
>
> > public function __construct($id = false, $table = null, $ds = null) {
> > parent::__construct($id, $table, $ds);
>
> > $this->Session = new CakeSession();
> > }
>
> > Any insight on how this breaks MVC?
>
> The request shoud be irrelevant to the model. That's for the
> controller to deal with. If you have model methods which are dependent
> on request data (which, essentially, is what session vars are) just
> pass them to your model methods from the controller.
>
> If you've got a lot of params to send, consider using an associative
> array, the way most everything else in Cake works.
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment