Re: Problem with DataObject and Update
| From: | bedo | Date: | Wed, 12 Apr 2006 14:31:03 +0000 |
| Subject: | Re: Problem with DataObject and Update | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23629@lists.php.net to get a copy of this message | ||
hello,
i guess problem might be with DB_DATAOBJECT_WHEREADD_ONLY according DB_DataObject->update() description at
http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.update.php
which will force ->update being build according to whereAdd rather then PK.
to get info about query your DataObject is actualy sending to DB, rise your debug lvl e.g. DB_DataObject::debugLevel(2);
so check if u not getting this error ;)
DBObj_Recipe: ERROR: update: trying to perform an update without the key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLY
good luck
jozef bednarik
----- Original Message ----- From: "Jose Manuel Zea" <jmzeag@yahoo.es>
To: <pear-general@lists.php.net>
Sent: Wednesday, April 12, 2006 3:38 PM
Subject: RV: [PEAR] Problem with DataObject and Update
Hi Arnaud.
Look at the example 33-3 at
http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.u
pdate.php . It´s very similar to what I´m doing.
-----Mensaje original-----
De: arnaud sellenet bodin [mailto:demental@free.fr]
Enviado el: miércoles, 12 de abril de 2006 15:01
Para: Jose Manuel Zea
CC: pear-general@lists.php.net
Asunto: Re: [PEAR] Problem with DataObject and Update
Hi
I've never used DB_DataObject this way, and I don't think it was
designed for this.
WhereAdd is only used in conjonction with find(). Then you have to
loop thru the result set using fetch() and update each row.
Otherwise you can use the query() method to send a raw query.
Le 12 avr. 06 à 13:56, Jose Manuel Zea a écrit :
Hi: Under PHP5 and using the last stable package for DB_DataObject, I´m having a problem when I try to update several rows. Some of the fields in the table are: CREATE TABLE-- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.4.0/306 - Release Date: 09/04/2006 ______________________________________________ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpinmuebles(codinmuebleint(10) unsigned NOT NULL auto_increment, (.)codpromocionint(11) default NULL,publicadotinyint(1) NOT NULL default '0', (.) PRIMARY KEY (codinmueble) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 When I want to update the field 'publicado' (means published, it´s a boolean value for me) to value 1 or 0 querying by the codpromocion value, I do for example the next thing: $data = new DO_Inmuebles; $data->publicado=1; $data->whereAdd('codpromocion=1'); if ($data->update()>0){ echo 'It works!!!'; } And nothing happens. But if I do the next, to update the value querying by the primary key: $data = new DO_Inmuebles; $data->publicado=1; $data ->do->get(1); if ($data->update()>0){ echo 'It works!!!'; } It seems it´s not working when need to update several rows instead of just one. Can anyone help me? Regards, Jose Manuel Zea ______________________________________________ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php