Re: [fw-general] delete, update params quoting

2010-12-07 Thread Fred Garlov
On Tue, Dec 7, 2010 at 4:49 PM, Hector Virgen  wrote:
> Hi Fred,
> From the documentation:
>>
>> If you provide an array of arrays as the third argument, the values will
>> be automatically quoted into the keys. These will then be joined together as
>> terms, separated by AND operators.
>
> http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.write.update
>
> Although I think the wording is a bit off. You don't need to pass in an
> "array of arrays", but instead just an associative array. So your call would
> look like this:
> $this->update($data, array('id = ?' => $obj->id));
> I hope this helps!

Hello Hector,

thanks for showing the other way :). I've just discovered it somewhere too.

For me, it would be more logical to pass where statement with
placeholders and an array with corresponding values.

$this->update($data, 'id = ? OR url = ?', array($obj->id, $obj->url));

Fred

> --
> Hector Virgen
> Sr. Web Developer
> http://www.virgentech.com
>
>
> On Mon, Dec 6, 2010 at 11:59 AM, Fred Garlov 
> wrote:
>>
>> Hello,
>>
>> is there any reason for not having auto quoting of query parameters
>> for delete() and update() methods?
>>
>> $this->update($data, $this->getAdapter()->quoteInto('id = ?', $obj->id));
>>
>> I mean, we have it for where() method: $query =
>> $this->select()->where('id = ?', $value);
>>
>> IMHO, it would be uniformly and easily like this:
>>
>> $this->update($data, 'id = ?', $obj->id);
>>
>> Regards, Fred
>
>


Re: [fw-general] delete, update params quoting

2010-12-07 Thread Hector Virgen
Hi Fred,

>From the documentation:

If you provide an array of arrays as the third argument, the values will be
> automatically quoted into the keys. These will then be joined together as
> terms, separated by AND operators.


http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.write.update

Although I think the wording is a bit off. You don't need to pass in an
"array of arrays", but instead just an associative array. So your call would
look like this:

$this->update($data, array('id = ?' => $obj->id));

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Dec 6, 2010 at 11:59 AM, Fred Garlov wrote:

> Hello,
>
> is there any reason for not having auto quoting of query parameters
> for delete() and update() methods?
>
> $this->update($data, $this->getAdapter()->quoteInto('id = ?', $obj->id));
>
> I mean, we have it for where() method: $query =
> $this->select()->where('id = ?', $value);
>
> IMHO, it would be uniformly and easily like this:
>
> $this->update($data, 'id = ?', $obj->id);
>
> Regards, Fred
>