RE: [Bulk] Re: RV: [PEAR] Problem with DataObject and Update
| From: | Jose Manuel Zea | Date: | Wed, 12 Apr 2006 14:54:16 +0000 |
| Subject: | RE: [Bulk] Re: RV: [PEAR] Problem with DataObject and Update | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23630@lists.php.net to get a copy of this message | ||
That´s it!
Now it works correctly, affecting all the rows.
Thank you Nicholas. (And Arnaud, and Jozef :-)).
¡Hasta otra!
-----Mensaje original-----
De: Nicholas Costa [mailto:ncosta@alum.rpi.edu]
Enviado el: miércoles, 12 de abril de 2006 16:05
Para: pear-general@lists.php.net
Asunto: [Bulk] Re: RV: [PEAR] Problem with DataObject and Update
Jose,
You need to use the constant DB_DATAOBJECT_WHEREADD_ONLY as the
argument to DB_DataObject::update(). This allows for multiple row
updates by ignoring the primary key field set for your table. It is
documented on http://pear.php.net/manual/en/package.database.db-
dataobject.db-dataobject.update.php . This sample should get you going:
$data = new DO_Inmuebles;
$data->publicado = 1;
$data->whereAdd( 'codpromocion = 1' );
if($data->update( DB_DATAOBJECT_WHEREADD_ONLY ) > 0) // passes
constant to update()
{
echo It works!!!;
}
Buena suerte!
HTH,
Nick
On Apr 12, 2006, at 9:38 AM, Jose Manuel Zea wrote:
> 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
inmuebles (
>> codinmueble int(10) unsigned NOT NULL auto_increment,
>> (
)
>> codpromocion int(11) default NULL,
>> publicado tinyint(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
>>
>>
>
> --
> 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.php
>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
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