On May 22, 7:07 am, shantamg <[email protected]> wrote:
> @Andrel: I'd love to be able to set the conditions in the model, but
> the model can't know what's in the session!
It can, you just need to load the Session object. Nothing wrong with
that (in my opinion)...
App::import('Core', 'CakeSession');
$Session = new CakeSession();
$myValue = $Sesssion->read('myValue');
etc.
Or just put it in your AppModel::__construct() function:
function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);
App::import('Core', 'CakeSession');
$this->_session = new CakeSession();
}
Then you've got a $this->_session variable in all of your models.
Someone uptight about a rigid MVC structure might have an objection,
but it does the job.
Then, if you go that route, you can add in schedule_id conditions in,
say, your AppModel::beforeFind() function:
function beforeFind($queryData) {
// Check $queryData['conditions'] array for schedule_id, add it if
it's not already there.
// Loop through $queryData['contain'] and add the condition to each
contained model
return $queryData;
}
That's just off the cuff, but it might be what you're looking for.
- Jamie
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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