more robust check for table not exists

should work on HHVM too
This commit is contained in:
Carsten Brandt
2014-06-12 14:45:41 +02:00
parent 87bac4bf9c
commit 9430ccd095
2 changed files with 2 additions and 2 deletions

View File

@ -453,7 +453,7 @@ class Schema extends Object
$columns = $this->db->createCommand($sql)->queryAll();
} catch (\Exception $e) {
$previous = $e->getPrevious();
if ($previous instanceof \PDOException && $previous->getCode() == '42S02') {
if ($previous instanceof \PDOException && strpos($previous->getMessage(), 'SQLSTATE[42S02') !== false) {
// index does not exist
return false;
}

View File

@ -188,7 +188,7 @@ class Schema extends \yii\db\Schema
$columns = $this->db->createCommand($sql)->queryAll();
} catch (\Exception $e) {
$previous = $e->getPrevious();
if ($previous instanceof \PDOException && $previous->getCode() == '42S02') {
if ($previous instanceof \PDOException && strpos($previous->getMessage(), 'SQLSTATE[42S02') !== false) {
// table does not exist
return false;
}