Following code snippet may help you
function beforeFind(&$queryData)
{
$conditions = $queryData['conditions'];
if (!is_array($conditions)) {
if (!$conditions) {
$conditions = array();
} else {
$conditions = array($conditions);
}
}
if (!isset($conditions['active']) && !isset($conditions[$this->alias .
'.active'])) {
$conditions[$this->alias . '.active'] = 1;
}
return true;
}
2009/2/5, Günther Theilen <[email protected]>:
>
>
> Hi!
>
> Is there as way to define default conditions in the model?
>
> Let's say I have a model with a field "active" which can be 0 or 1.
> In most queries I need the condition "active = 1" but sometimes I need
> the condition "active in (0,1)".
>
> Is there a way to define "active = 1" as the default condition for these
> queries? So I don't have to add it to each query and only overwrite it
> with "active in (0,1)" if needed.
>
> Regards
> Guenther
>
>
> >
>
--
Amit
http://amitrb.wordpress.com/
http://coppermine-gallery.net/
http://cheesecake-photoblog.org/
http://www.sanisoft.com/blog/author/amitbadkas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---