Mysql Safe Update
Mysql Safe Update
Allan
I got following error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2' in /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php:98
Stack trace:
#0 /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php(98): PDOStatement->execute()
#1 /var/www/consultas/_/EE/php/lib/Database/Query.php(598): DataTables\Database\DriverMysqlQuery->_exec()
#2 /var/www/consultas/_/EE/php/lib/Database/Query.php(206): DataTables\Database\Query->_raw('DELETE FROM not...')
#3 /var/www/consultas/_/EE/php/lib/Database/Database.php(215): DataTables\Database\Query->exec('DELETE FROM not...')
#4 /var/www/consultas/_/EE/php/table.EEofertas.php(69): DataTables\Database->sql('DELETE FROM not...')
#5 {main}
thrown in /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php on line 98
The line is:
// Delete notas which are part of ofertas
$db->sql( "DELETE FROM notas WHERE id IN (
SELECT idnota FROM ofertas WHERE id IN ( ".implode(', ', $ids)." )"
);
I did type the sql in MySQLWorkbench and did not work until I disable the option "Safe Update". So I am sure that the code is OK but seems that I need to disable safe update from some place in Editor.
Any help?
I got following error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2' in /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php:98
Stack trace:
#0 /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php(98): PDOStatement->execute()
#1 /var/www/consultas/_/EE/php/lib/Database/Query.php(598): DataTables\Database\DriverMysqlQuery->_exec()
#2 /var/www/consultas/_/EE/php/lib/Database/Query.php(206): DataTables\Database\Query->_raw('DELETE FROM not...')
#3 /var/www/consultas/_/EE/php/lib/Database/Database.php(215): DataTables\Database\Query->exec('DELETE FROM not...')
#4 /var/www/consultas/_/EE/php/table.EEofertas.php(69): DataTables\Database->sql('DELETE FROM not...')
#5 {main}
thrown in /var/www/consultas/_/EE/php/lib/Database/Driver/Mysql/Query.php on line 98
The line is:
// Delete notas which are part of ofertas
$db->sql( "DELETE FROM notas WHERE id IN (
SELECT idnota FROM ofertas WHERE id IN ( ".implode(', ', $ids)." )"
);
I did type the sql in MySQLWorkbench and did not work until I disable the option "Safe Update". So I am sure that the code is OK but seems that I need to disable safe update from some place in Editor.
Any help?
This discussion has been closed.
Replies
Allan
// DELETING THE ROW IN NOTAS
if ( isset( $_POST['action'] ) && $_POST['action'] === 'remove' ) {
$ids = array();
// Build array of ofertas ids
for ( $i=0 ; $isql( "DELETE FROM notas WHERE id IN (
SELECT idnota FROM ofertas WHERE id IN ( ".implode(', ', $ids)." )"
);
}
I did echo the generated SQL paste in Workbench and Works ok (with safe mode disable).
D0 you think that there is a syntax error in the generation of $ids????
There is a ) missing!!