I’m doing an adjacency list model for a hierarchical menu system and while doing the sorting of menu items I ran into an issue with Zend_Db_Adapter::update().
public function up($cls)
{
$table = $this->getDbTable();
$adapter = $table->getAdapter();
$data = array('priority' => 'priority - 1');
$where = array($adapter->quoteInto('id = ?', $cls->getId()));
$table->update($data, $where);
}
When the up() method is ran it sets the priority field to 0 which is incorrect. The code below which was written manually works as expected.
public function up($cls)
{
$table = $this->getDbTable();
$adapter = $table->getAdapter();
// Works fine
$sql = "UPDATE `menu` SET priority = (priority-1) WHERE id = " . $cls->getId();
$adapter->query($sql);
}
Perhaps I’m not using the function properly but this is an oddity that should be addressed.
GD Star Rating
loading...
loading...