Mensagem sobre o tópico
Cake - Insert ao invez de update
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"data[Gallery][id]"<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; $this->layout=3D'admin';<br><br> &nbs=
p; if (!empty($this->data)) {<br>
if ($this->Gallery->save($=
this->data)) {<br> =
$this->Session->setFlash(__('The Gallery has been sa=
ved', true));<br> =
$this->redirect(array('action'=3D>'index'=
;));<br>
} else {<br> &n=
bsp; $this->Session->setFla=
sh(__('The Gallery could not be saved. Please, try again.', true));=
<br> }<br> } el=
se {<br> if (!$id) {<br> &nb=
sp; $this->Session=
->setFlash(__('Invalid Gallery', true));<br>
$this-&g=
t;redirect(array('action'=3D>'index'));<br> &=
nbsp; }<br><br> =
$this->data =3D $this->Gallery->read(null, $id);<br> &=
nbsp; }<br><br> $categories =3D $this->Gallery-&=
gt;Category->find('list',array('fields'=3D>array('=
;Category.id', 'Category.titulo'), 'value'=3D>'C=
ategory.id'));<br>
$packages =3D $this->Package->find('list',=
array('fields'=3D>array('Package.id', 'Package.titu=
lo'), 'value'=3D>'Package.id'));<br> &nbs=
p; $this->set(compact('categories', 'packages'));<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--