Al final lo he solucionado poniendo un beforeFind en el modelo en
cuestión, pero teniendo en cuenta que conditions puede venir como
texto o como array:

        function beforeFind(&$queryData) { //Filtra los productos activos

             if (!is_array($queryData['conditions'])) {
                                $sql = ($queryData['conditions']!='') ? ' AND ' 
: ''.
                                $queryData['conditions'] = $sql . 
'Producto.activo = 1';
                         }else{
                                 $queryData['conditions'][] = 'Producto.activo 
= 1';
                         }


             return $queryData;

        }



On 11 ago, 23:14, "Pablo Viojo" <[EMAIL PROTECTED]> wrote:
> Exacto, eso es bueno también. Como ejemplo te paso un código que
> utilizo (tomado de [1] y ajustado un poco) obviamente tenes que
> ajustarlo ;)
>
> class SingleInheritanceAppModel extends AppModel{
>
>         var $__fields = array();
>
>         function __construct($id = false,$ignore_table = null, $ds = null)
>         {
>                 $table = $this->__table;
>                 parent::__construct($id,$table,$ds);
>         }
>
>         function findAll($conditions = null, $fields = null, $order = null,
> $limit = null, $page = 1, $recursive = null)
>         {
>                 if($conditions == null)
>                 {
>                         $conditions = $this->name. "." . $this->__type_field 
> . " = '" .
> $this->__type_value . "'";
>                 }
>                 else
>                 {
>                         $conditions = $conditions . " AND " . $this->name . 
> "." .
> $this->__type_field . " = '" . $this->__type_value . "'";
>                 }
>
>                 if($fields == null)
>                 {
>                         $fields = $this->__fields;
>                 }
>                 else
>                 {
>                         foreach($fields AS $field)
>                         {
>                                 if(!array_search($field,$this->__fields))
>                                 {
>                                         throw new Exception("Field " . $field 
> . " does not exist in Model
> " . $this->name);
>                                 }
>                         }
>                 }
>
>                 return parent::findAll($conditions, $fields, $order, $limit, 
> $page,
> $recursive);
>         }
>
>         function findCount($conditions = null, $recursive = 0)
>         {
>                 if($conditions == null)
>                 {
>                         $conditions = $this->name . "." . $this->__type_field 
> . " = '" .
> $this->__type_value . "'";
>                 }
>                 else
>                 {
>                         $conditions = $conditions . " AND " . $this->name . 
> "." .
> $this->__type_field . " = '" . $this->__type_value . "'";
>                 }
>                 return parent::findCount($conditions, $recursive);
>         }
>
>         function findAllThreaded($conditions = null, $fields = null, $sort = 
> null)
>         {
>                 if($conditions == null)
>                 {
>                         $conditions = $this->__table . "." . 
> $this->__type_field . " = '" .
> $this->__type_value . "'";
>                 }
>                 else
>                 {
>                         $conditions = $conditions . " AND " . $this->name . 
> "." .
> $this->__type_field . " = '" . $this->__type_value . "'";
>                 }
>                 if($fields == null)
>                 {
>                         $fields = $this->__fields;
>                 }
>                 else
>                 {
>                         foreach($fields AS $field)
>                         {
>                                 if(!array_search($field,$this->__fields))
>                                 {
>                                         throw new Exception("Field " . $field 
> . " does not exist in Model
> " . $this->name);
>                                 }
>                         }
>                 }
>                 return parent::findAllThreaded($conditions, $fields, $sort);
>         }
>
>         function save($data = null, $validate = true, $fieldList = array())
>         {
>                 $data[$this->name][$this->__type_field] = $this->__type_value;
>                 return parent::save($data, $validate, $fieldList);
>         }
>
> }
>
> Saludos,
> --
> Pablo Viojo
> [EMAIL PROTECTED]://pviojo.net
>
> [1]http://www.ifisgeek.com/tutorials/implementing_single_table_inheritan...
>
> On 8/10/07, Pablo Moretti <[EMAIL PROTECTED]> wrote:
>
> > Tambien podes usar la herencia y reescribir el metodo finall en appmodel y
> > lo heredan todas las clases
> > o escribir el metodo findallAcvitas que termina llamando al app y le pasa
> > todos los parametros + el array con la condicion.
>
> > Hay que aprobechar la POO !!!!!!
> > saludos


--~--~---------~--~----~------------~-------~--~----~
Has recibido este mensaje porque estás suscrito a Grupo "CakePHP-es" de Grupos 
de Google.
 Si quieres publicar en este grupo, envía un mensaje de correo 
electrónico a [email protected]
 Para anular la suscripción a este grupo, envía un mensaje a [EMAIL PROTECTED]
 Para obtener más opciones, visita este grupo en 
http://groups.google.com/group/CakePHP-es?hl=es.

-~----------~----~----~----~------~----~------~--~---

Responder a