I have a schema sql file (with syntax error) including several queries for the settings database
example.sql
CREATE TABLE IF NOT EXISTS `example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; CREATExxxxxxxxxx TABLE IF NOT EXISTS `example2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
example.php
$sqlContent = file_get_contents("example.sql"); $stmt = $conn->prepare($sqlContent); $result = $stmt->execute();
The execute method throws no exceptions, even if my sql is incorrect. it reports that it returns false on error, but returns true .
How do I do exception handling? How to check if my request has an error message?
source share