0

my sql-query doesn't work. here is my query.

   public function deletes($poss) {
       $where = array('pos > ?' => $poss);
       $this->update(['pos' => 'pos - 1'], $where);
}

it's seems he does every pos -1 instead of the ones greater than $poss.

please help.

  • This code works as it should. It sets word `pos-1` in `pos` column for all fields where `pos` column was greater than `$poss`. Is this what you wanted? – Volvox Sep 03 '15 at 14:28

1 Answers1

1

Try using Zend_Db_Expr.

Like:

$where = array('pos > ?' => $poss);
$this -> update(array('pos' => new Zend_Db_Expr('pos - 1')), $where);
Pushpendra
  • 4,344
  • 5
  • 36
  • 64