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]
http://pviojo.net

[1] 
http://www.ifisgeek.com/tutorials/implementing_single_table_inheritance_in_cakephp

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