Re: Problem with DataObject and Update
| From: | arnaud sellenet bodin | Date: | Wed, 12 Apr 2006 13:00:37 +0000 |
| Subject: | Re: Problem with DataObject and Update | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23625@lists.php.net to get a copy of this message | ||
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 TABLEinmuebles(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