My MySQL DBMS has a table called elements where one of the fields is called posicao
and is of type int (6)
.
I need to perform an update (SQL) where the posicao
field should be updated with its own value subtracting 1 according to the where
clause. The following query (SQL) does this:
UPDATE elementos
SET posicao = (posicao - 1)
WHERE posicao > 9
Converting this query to use in the model, one of the attempts I made was this, but it did not roll:
$db = new Application_Model_DbTable_Elemento();
$dados = array(
'posicao' => (posicao - 1)
);
$where = $db->getAdapter()->quoteInto('posicao > ?', 9);
$db->update($dados, $where);
I believe the problem is in the data set in the $dados
array. How would the syntax to execute this UPDATE
?