I'm trying to execute multiple queries, but something is wrong.
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$sql = "
UPDATE tmatria SET par = " . $newpar . ", inde = " . $newinde . " WHERE id =" . $cutid . ";
SELECT * FROM tmatria ORDER BY inde ASC;
SET @i := 0;
UPDATE tmatria SET inde = @i := @i + 1;
";
try {
$db->exec($sql);
}
catch (PDOException $e) {
echo $e->getMessage();
die();
}
I want update some columns, then sort table by inde column and finally set inde values to 1 2 3...
I think lines UPDATE tmatria SET par... and SELECT * FROM tmatria ORDER BY inde ASC; are critical, but cannot see what's wrong.
Any help?
indecolumn is set to1 2 3...before table is sorted byindecolumn. In fact it is not sorted at all.