public function __construct($maximumValidation, $tableName) { if (!$this->isDatabaseSupported(\Yii::$app->db->dsn)) { throw new Exception(DATABASE_IS_NOT_SUPPORTED); } if (isset(MySqlTableSchemaParser::$describeTable[$tableName])) { $tableSchemaRowList = MySqlTableSchemaParser::$describeTable[$tableName]; } else { $command = \Yii::$app->db->createCommand('DESCRIBE ' . $tableName); $tableSchemaRowList = $command->queryAll(); MySqlTableSchemaParser::$describeTable[$tableName] = $tableSchemaRowList; $command = \Yii::$app->db->createCommand('SHOW CREATE TABLE ' . $tableName); $tableSchemaStr = $command->queryAll(); MySqlTableSchemaParser::$showCreateTable[$tableName] = $tableSchemaStr[0]['Create Table']; } $tableSchemaParser = new $this->tableSchemaParserClass($this, $tableName, $tableSchemaRowList, $maximumValidation); parent::__construct(); }
public function __construct($tableName, $dsn, $pdo) { if (!$this->isDatabaseSupported($dsn)) { throw new Exception(DATABASE_IS_NOT_SUPPORTED); } if (isset(MySqlTableSchemaParser::$describeTable[$tableName])) { $tableSchemaRowList = MySqlTableSchemaParser::$describeTable[$tableName]; } else { $pdoAttributeATTR_CASE = $pdo->getAttribute(\PDO::ATTR_CASE); $pdo->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL); $pdoStatement = $pdo->query('DESCRIBE ' . $tableName); $tableSchemaRowList = $pdoStatement->fetchAll(\PDO::FETCH_ASSOC); MySqlTableSchemaParser::$describeTable[$tableName] = $tableSchemaRowList; $pdoStatement = $pdo->query('SHOW CREATE TABLE ' . $tableName); $tableSchemaStr = $pdoStatement->fetchAll(\PDO::FETCH_ASSOC); MySqlTableSchemaParser::$showCreateTable[$tableName] = $tableSchemaStr[0]['Create Table']; $pdo->setAttribute(\PDO::ATTR_CASE, $pdoAttributeATTR_CASE); } $tableSchemaParser = new $this->tableSchemaParserClass($this, $tableName, $tableSchemaRowList, true); parent::__construct(); }