Any ideas? The following doesn't work either:
[php]
public function editMore(array $ids, array $data)
{
$ids = implode($ids, ', ');
$ids = '(' . $ids . ')';
return $this->update($data, $this->getAdapter()->quoteInto('id IN ?', $ids));
}
[/php]
Hello,
Is it possible to use WHERE IN or WHERE BETWEEN instead of simple WHERE in Zend_Db_Table?
I have tried for example:
[php]
public function editMore(array $ids, array $data)
{
$ids = implode($ids, ', ');
return $this->update($data, $this->getAdapter()->quoteInto('id IN (?)', $ids));
}
[/php]
Where $ids looks like array(1, 2, 3) for example. And it didn't work.
Last edited by risoknop; 02-21-2009 at 01:08 PM.
Any ideas? The following doesn't work either:
[php]
public function editMore(array $ids, array $data)
{
$ids = implode($ids, ', ');
$ids = '(' . $ids . ')';
return $this->update($data, $this->getAdapter()->quoteInto('id IN ?', $ids));
}
[/php]
Solved... I have figured it out![]()
How about sharing your solution with the rest of the group? That way, others who come later may not have to ask the same question.
There are tons of ways you can do this... here's one:[php]public function editMore(array $ids, array $data)
{
$ids = implode(array_map('intval', $ids), ',');
return $this->update($data, "id in ($ids)");
} [/php]
WHERE IN is a great solution but it only works with numbers.
I wanted it to work with chars too but it's not the case...
It does work with other types, you just need to make sure you quote all the values in the list.
Brenton Alker
PHP Developer - Brisbane, Australia
blog.tekerson.com | twitter.com/tekerson | brenton.mp