Doctrine Error Handling while Executing Multiple Queries #4971

Closed
opened 2026-01-22 14:54:49 +01:00 by admin · 1 comment
Owner

Originally created by @feridmovsumov on GitHub (Jan 13, 2016).

Originally assigned to: @deeky666 on GitHub.

I have an schema sql file (with syntax error) including multiple queries for 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();

execute method doesn't throw any exception even that my sql is incorrect. it documentation says it returns false on failure but it returns true.

How should I do exception hanling here? How can I check if my query has an error?

I asked question on StackOverflow: http://stackoverflow.com/questions/34766314/doctrine-error-handling-while-executing-multiple-queries

Originally created by @feridmovsumov on GitHub (Jan 13, 2016). Originally assigned to: @deeky666 on GitHub. I have an schema sql file (with syntax error) including multiple queries for settings database example.sql ``` 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 ``` php $sqlContent = file_get_contents("example.sql"); $stmt = $conn->prepare($sqlContent); $result = $stmt->execute(); ``` execute method doesn't throw any exception even that my sql is incorrect. it documentation says it returns false on failure but it returns true. How should I do exception hanling here? How can I check if my query has an error? I asked question on StackOverflow: http://stackoverflow.com/questions/34766314/doctrine-error-handling-while-executing-multiple-queries
admin added the Duplicate label 2026-01-22 14:54:49 +01:00
admin closed this issue 2026-01-22 14:54:49 +01:00
Author
Owner

@deeky666 commented on GitHub (Jan 13, 2016):

Closing this as duplicate in favour of https://github.com/doctrine/dbal/issues/2299 which is the right place for the discussion.

@deeky666 commented on GitHub (Jan 13, 2016): Closing this as duplicate in favour of https://github.com/doctrine/dbal/issues/2299 which is the right place for the discussion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4971