Orkut Gmail Agenda Docs Web mais »
Grupos visitados recentemente | Ajuda | Acessar
Página inicial dos Grupos do Google
Mensagem sobre o tópico Cake - Insert ao invez de update

Visualizar analisado - Mostrar apenas o texto da mensagem ??

Received: by 10.100.3.4 with SMTP id 4mr3861290anc.15.1222725515018;
        Mon, 29 Sep 2008 14:58:35 -0700 (PDT)
Return-Path: <guilherme.dco...@gmail.com>
Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.245])
        by mx.google.com with ESMTP id 22si1551825yxr.1.2008.09.29.14.58.34;
        Mon, 29 Sep 2008 14:58:34 -0700 (PDT)
Received-SPF: pass (google.com: domain of guilherme.dco...@gmail.com designates 209.85.132.245 as permitted sender) client-ip=209.85.132.245;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of guilherme.dco...@gmail.com designates 209.85.132.245 as permitted sender) smtp.mail=guilherme.dco...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by an-out-0708.google.com with SMTP id b21so116639ana.35
        for <arqhp@googlegroups.com>; Mon, 29 Sep 2008 14:58:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to
         :subject:in-reply-to:mime-version:content-type:references;
        bh=X/Yx/qXdnqv23Z5LZ3sY04y7XM6Iauw3/Hb7RKV0RhE=;
        b=PfhMTp3LKtbA2//0xn3IsgNfUiMmgUwdqnKgd0CjsHM3woNSBsJhhBgYmy6ObmaB+U
         UbspP17iop1e9jUSOcSU1Ym8sv4RrTCdAooLItsw+p83jLV8HZdEf1JlF1Kh6pYlULu3
         5Ri6miMtluBXs3hDa9n+ULCakV0ouL2u85WBs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:in-reply-to:mime-version
         :content-type:references;
        b=FxitlkwGBLyyLQQsPH8xN8ft8MKxTrztUDwD+M2L6wOQVZdr+E/0cSIjku4+/fliyg
         4QvpQHG7QKffES2/tfvOjQMrBOp/QR2kMex/MI09gIjp+Ou0QuF5bQbtyp0DHF3jmJKD
         /+CQ0BPB5rjY6a2mgtq/rvBLUl0p3oFy6FxvU=
Received: by 10.100.173.18 with SMTP id v18mr5036017ane.122.1222725513887;
        Mon, 29 Sep 2008 14:58:33 -0700 (PDT)
Received: by 10.100.226.11 with HTTP; Mon, 29 Sep 2008 14:58:33 -0700 (PDT)
Message-ID: <c5aa32730809291458w173f8a77tb019c8ed940043b1@mail.gmail.com>
Date: Mon, 29 Sep 2008 18:58:33 -0300
From: "Guilherme David da Costa" <guilherme.dco...@gmail.com>
To: arqhp@googlegroups.com
Subject: Re: [arqHP: 40414] Re: Cake - Insert ao invez de update
In-Reply-To: <fbd6d94d0809251339s70e284b4x6fa6fc8415d39...@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_36191_19474704.1222725513904"
References: <92DEFC36193D4C099D7E36800545F80C@NoteJoao>
	 <fbd6d94d0809251339s70e284b4x6fa6fc8415d39...@mail.gmail.com>

------=_Part_36191_19474704.1222725513904
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Concordo com o Danilo.
Ve se voc=EA n=E3o est=E1 esquecendo um input hidden com name=3D"data[Galle=
ry][id]"
Voce tem que colocar o id do registro que voce queira dar o update dentro
deste input.

Sem querer ser chato, mas voce poderia dar uma otimizada nesse c=F3digo n=
=E9?
Talvez usar isso:

function admin_edit($id =3D null) {
    $this->layout=3D'admin';

    if (!empty($this->data)) {
        if ($this->Gallery->save($this->data)) {
            $this->Session->setFlash(__('The Gallery has been saved',
true));
            $this->redirect(array('action'=3D>'index'));
        } else {
            $this->Session->setFlash(__('The Gallery could not be saved.
Please, try again.', true));
        }
    } else {
        if (!$id) {
            $this->Session->setFlash(__('Invalid Gallery', true));
            $this->redirect(array('action'=3D>'index'));
        }

        $this->data =3D $this->Gallery->read(null, $id);
    }

    $categories =3D
$this->Gallery->Category->find('list',array('fields'=3D>array('Category.id'=
,
'Category.titulo'), 'value'=3D>'Category.id'));
    $packages =3D $this->Package->find('list',
array('fields'=3D>array('Package.id', 'Package.titulo'),
'value'=3D>'Package.id'));
    $this->set(compact('categories', 'packages'));
}

E no model eliminar todas as colunas que estiverem atribuindo valores vazio=
s
nos arrays.
Ficaria mais leg=EDvel.

------=_Part_36191_19474704.1222725513904
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div dir=3D"ltr">Concordo com o Danilo.<br>Ve se voc=EA n=E3o est=E1 esquec=
endo um input hidden com name=3D&quot;data[Gallery][id]&quot;<br>Voce tem q=
ue colocar o id do registro que voce queira dar o update dentro deste input=
.<br><br>
Sem querer ser chato, mas voce poderia dar uma otimizada nesse c=F3digo n=
=E9?<br>Talvez usar isso:<br><br>function admin_edit($id =3D null) {<br>&nb=
sp;&nbsp;&nbsp; $this-&gt;layout=3D&#39;admin&#39;;<br><br>&nbsp;&nbsp;&nbs=
p; if (!empty($this-&gt;data)) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($this-&gt;Gallery-&gt;save($=
this-&gt;data)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; $this-&gt;Session-&gt;setFlash(__(&#39;The Gallery has been sa=
ved&#39;, true));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; $this-&gt;redirect(array(&#39;action&#39;=3D&gt;&#39;index&#39=
;));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;Session-&gt;setFla=
sh(__(&#39;The Gallery could not be saved. Please, try again.&#39;, true));=
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; } el=
se {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$id) {<br>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;Session=
-&gt;setFlash(__(&#39;Invalid Gallery&#39;, true));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&g=
t;redirect(array(&#39;action&#39;=3D&gt;&#39;index&#39;));<br>&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp; $this-&gt;data =3D $this-&gt;Gallery-&gt;read(null, $id);<br>&nbsp;&=
nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; $categories =3D $this-&gt;Gallery-&=
gt;Category-&gt;find(&#39;list&#39;,array(&#39;fields&#39;=3D&gt;array(&#39=
;Category.id&#39;, &#39;Category.titulo&#39;), &#39;value&#39;=3D&gt;&#39;C=
ategory.id&#39;));<br>
&nbsp;&nbsp;&nbsp; $packages =3D $this-&gt;Package-&gt;find(&#39;list&#39;,=
 array(&#39;fields&#39;=3D&gt;array(&#39;Package.id&#39;, &#39;Package.titu=
lo&#39;), &#39;value&#39;=3D&gt;&#39;Package.id&#39;));<br>&nbsp;&nbsp;&nbs=
p; $this-&gt;set(compact(&#39;categories&#39;, &#39;packages&#39;));<br>
}<br><br>E no model eliminar todas as colunas que estiverem atribuindo valo=
res vazios nos arrays.<br>Ficaria mais leg=EDvel.<br></div>

------=_Part_36191_19474704.1222725513904--

Criar um grupo - Grupos do Google - Página inicial do Google - Termos de Uso - Política de Privacidade
©2009 Google