Im trying to update the entire column, but it seems to only update the first matching row.
This is my code
$sql = 'UPDATE tree SET sort_order = sort_order+1 WHERE sort_order > :sort_order AND reply_to = :id';
$query = $app->getConnection()->prepare($sql);
$query->execute(array(':sort_order' => get_sort(),
':id' =>$id
));
How do i update the column? I know there are more matches their.
but it seems to only update the first matching row
Yeah, cause you have used a filter using WHERE
clause as seen below
WHERE sort_order > :sort_order AND reply_to = :id'
if you want to update all rows then remove the WHERE
condition
UPDATE tree SET sort_order = sort_order+1;