cake-php
[Arriba] [Todas las Listas]

Re: Consigue registro viejo en beforeSave cuando actualizando (haciendo

To: cake-php@xxxxxxxxxxxxxxxx
Subject: Re: Consigue registro viejo en beforeSave cuando actualizando (haciendo un $esto->encontrar() dentro de beforeSave callback)
From: AD7six <andydawson76@xxxxxxxxx>
Date: Sun, 30 Jun 2013 11:37:18 -0700 (PDT)
Delivery-date: Sun, 30 Jun 2013 14:37:27 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=UVKBzKsZbTXI/Vgj9C7EefeRWYMcvKAOBBL51zzMkcI=; b=UUoKSOFkxXkothrlEXGVJVauEmUX0ZoVnP5BvcTkYt+Uzg9HwUpMKPo6lOW8VGWBI5 z7Sok1Q0m7r1/npb5A8bjW00ZIwwXnncsbv3GgAOxiujt6vCuHzLqNlHkw0V5FpQsR3r d/iY0tixzSDs33O78AhUNqnNwgKS21bflphNZrpEDcf7p/CPGmLgrtMlT9As4I93hgSd +NH61cjA4HZqF4hJANM5U2w1eN+OJk6uGiO77wrfHlswh8ekZNyiz9PnMrhfrMtXKHgP pl3V6/YUfhyfLTROAUikv2h1ugL/qZ+tTeQRiqKfUgq2OZr88/woIOYwhkDomDPqZVB+ xuxw==
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=UVKBzKsZbTXI/Vgj9C7EefeRWYMcvKAOBBL51zzMkcI=; b=lAI185hhzgIR3lR0vMBSTeD5UqeNvHfD8eBsA8CMGXReXvq42z6HzJeXq2GvTrgYBk kMQSIvKJzHQM9yhMc/HNvvZQPavEjxD55Qwx/ZNE7pzpY4KLUxhiEAacMjgnpUWz+OeT xxekjAwNWxCbkT9yBfM59VBRVPkbi+HMUuZxxRVdO2tjvTdZ3CCRHvfVjJGxgTa/AdtD RQC1XDWJmVbPB79egVp/vZbZ08vD3sQiSjIZWjWkpM/FBW8C0h4SzywKrDnqWaPCknM2 kPdE+qVFiM3LAhLBtDZZuG5EtOZcub4S2WuCg11Qs1/I1bHVlVz3C902730ue2SzyWR/ iafg==
Envelope-to: traductor@xxxxxxxxxxx
In-reply-to: <9eadfb35-65dc-4cff-8760-acc025ab77f0@googlegroups.com>
List-archive: <http://groups.google.com/group/cake-php>
List-help: <http://groups.google.com/support/>, <mailto:cake-php+help@googlegroups.com>
List-id: <cake-php.googlegroups.com>
List-post: <http://groups.google.com/group/cake-php/post>, <mailto:cake-php@googlegroups.com>
List-subscribe: <http://groups.google.com/group/cake-php/subscribe>, <mailto:cake-php+subscribe@googlegroups.com>
List-unsubscribe: <http://groups.google.com/group/cake-php/subscribe>, <mailto:googlegroups-manage+1003367825667+unsubscribe@googlegroups.com>
Mailing-list: list cake-php@xxxxxxxxxxxxxxxx; contact cake-php+owners@xxxxxxxxxxxxxxxx
References: <87ea05b6-68aa-41d1-9a64-4ec3b8771d82@googlegroups.com> <CAM39fjy+1iTQPM0UKNZnQv1rv5dPb1b5GZ6pJu+wswW9O0wrmA@mail.gmail.com> <9eadfb35-65dc-4cff-8760-acc025ab77f0@googlegroups.com>
Reply-to: cake-php@xxxxxxxxxxxxxxxx
Sender: cake-php@xxxxxxxxxxxxxxxx

En sábado, 29 junio 2013 21:14:31 *UTC+2, *Vanja *Dizdarević escribió:
>
> *Thanks *MorFer, que es una solución sencilla, pero siente como *meddling con Modelo. 
> En el punto del encontrar, el modelo es en el salvar el ciclo y yo no saben lo que más un encontrar() podría cambiar en él.
>
> *Btw, *$esto->dato* Y *$esto->*id* tendría que ser salvado. El *id *se tendría que quedar 
> igual, pero nunca sabes. 
>
> Esto siente más limpio, pero estoy preguntándome sobre el elevado:
>
>             $Modelo = *ClassRegistry::*init('Usuario');
>             $consulta = [
>                  '*recursive' => 0, 
>                  'condiciones' => [$esto->*alias.'.'.$Esto->*primaryKey => 
> $esto->dato[$esto->*alias][$esto->*primaryKey]]
>             ];
>             $*oldData = $Modelo->encontrar('primero', $consulta);
>

Si tú  que dentro del modelo de Usuario - $esto y $el Modelo son exactamente el mismo 
objeto.

ANUNCIO

-- 
Gustarnos en *FaceBook *https://www.facebook.com/*CakePHP
nos Encuentra en *Twitter *http://*twitter.*com/*CakePHP

--- 
Recibiste este mensaje porque eres *subscribed al *Google Grupos "*CakePHP" grupo.
A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un *email a pastel-*php+unsubscribe@xxxxxxxxxxxxxxxx.
A correo a este grupo, envía *email a pastel-php@xxxxxxxxxxxxxxxx.
Visita este grupo en *http://grupos.*google.*com/Pastel/de grupo-*php.
Para más opciones, visita *https://grupos.*google.*com/Los Grupos/optan_fuera.



On Saturday, 29 June 2013 21:14:31 UTC+2, Vanja Dizdarević wrote:
>
> Thanks MorFer, that is a simple solution, but it feels like meddling with 
> Model. At the point of the find, the model is in the save cycle and I don't 
> know what else a find() might change in it.
>
> Btw, *$this->data* AND *$this->id* should be saved. The id *should* stay 
> the same, but you never know. 
>
> This feels cleaner, but I'm wondering about the overhead:
>
>             $Model = ClassRegistry::init('User');
>             $query = [
>                  'recursive' => 0, 
>                  'conditions' => [$this->alias.'.'.$this->primaryKey => 
> $this->data[$this->alias][$this->primaryKey]]
>             ];
>             $oldData = $Model->find('first', $query);
>

If you do that inside the User model - $this and $Model are exactly the 
same object.

AD

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


<Anterior por Tema] Tema Actual [Siguiente por Tema>