Piwik\Updater\Migration\Db\Sql::__construct PHP Метод

__construct() публичный Метод

Sql constructor.
public __construct ( string $sql, integer | int[] $errorCodesToIgnore )
$sql string
$errorCodesToIgnore integer | int[] If no error should be ignored use an empty array.
    public function __construct($sql, $errorCodesToIgnore)
    {
        if (!is_array($errorCodesToIgnore)) {
            $errorCodesToIgnore = array($errorCodesToIgnore);
        }
        $this->sql = $sql;
        $this->errorCodesToIgnore = $errorCodesToIgnore;
    }

Usage Example

Пример #1
0
 /**
  * Constructor.
  * @param Db\Settings $dbSettings
  * @param string $table Prefixed table name
  * @param string|string[] $columnNames array(columnName => columnValue)
  * @param string|string[] $primaryKey one or multiple columns that define the primary key
  */
 public function __construct(Db\Settings $dbSettings, $table, $columnNames, $primaryKey)
 {
     $columns = array();
     foreach ($columnNames as $column => $type) {
         $columns[] = sprintf('`%s` %s', $column, $type);
     }
     if (!empty($primaryKey)) {
         $columns[] = sprintf('PRIMARY KEY ( `%s` )', implode('`, `', $primaryKey));
     }
     $sql = sprintf('CREATE TABLE `%s` (%s) ENGINE=%s DEFAULT CHARSET=utf8', $table, implode(', ', $columns), $dbSettings->getEngine());
     parent::__construct($sql, static::ERROR_CODE_TABLE_EXISTS);
 }
All Usage Examples Of Piwik\Updater\Migration\Db\Sql::__construct