I want to truncate a table via PHP. It has some foreign keys, so I use the little trick where I set my foreign key check to zero:
$query_truncate_extension = "SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE extension; SET FOREIGN_KEY_CHECKS = 1;";
When I execute the script, the mysqli_error() gives me the following error:
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 'TRUNCATE TABLE extension; SET FOREIGN_KEY_CHECKS = 1' at line 1
So my table doesn't get truncated at all. But the weird thing is when I put this exact same query in the SQL-query section in phpmyadmin, it doesn't throw an error at all and my table is empty afterwards.
So my question is: why does this code gives an error in PHP, but not in phpmyadmin and how do I solve this?
Thanks in advance!