本文整理汇总了PHP中Sql::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::__construct方法的具体用法?PHP Sql::__construct怎么用?PHP Sql::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::__construct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* AddIndex constructor.
* @param string $table
* @param array $columnNames
* @param string $indexName
*/
public function __construct($table, $columnNames, $indexName)
{
$columns = array();
$columnNamesOnly = array();
foreach ($columnNames as $columnName) {
$columnName = str_replace(' ', '', $columnName);
// eg "column_name (10)" => "column_name(10)"
preg_match('/^([\\w]+)(\\(?\\d*\\)?)$/', $columnName, $matches);
// match "column_name" and "column_name(10)"
$nameOnly = $matches[1];
// eg "column_name"
$columnNamesOnly[] = $nameOnly;
$column = "`{$nameOnly}`";
if (!empty($matches[2])) {
$column .= ' ' . $matches[2];
// eg "(10)"
}
$columns[] = $column;
}
if (empty($indexName)) {
$indexName = $this->indexNamePrefix . '_' . implode('_', $columnNamesOnly);
}
$sql = sprintf("ALTER TABLE `%s` ADD %s %s (%s)", $table, $this->indexType, $indexName, implode(', ', $columns));
parent::__construct($sql, array(static::ERROR_CODE_DUPLICATE_KEY, static::ERROR_CODE_KEY_COLUMN_NOT_EXISTS));
}
示例2: __construct
public function __construct($table, $columnName, $columnType, $placeColumnAfter)
{
$sql = sprintf("ALTER TABLE `%s` ADD COLUMN `%s` %s", $table, $columnName, $columnType);
if (!empty($placeColumnAfter)) {
$sql .= sprintf(' AFTER `%s`', $placeColumnAfter);
}
parent::__construct($sql, static::ERROR_CODE_DUPLICATE_COLUMN);
}
示例3: __construct
public function __construct($table, $columnName)
{
$sql = sprintf("ALTER TABLE `%s` DROP COLUMN `%s`", $table, $columnName);
if (!empty($placeColumnAfter)) {
$sql .= sprintf(' AFTER `%s`', $placeColumnAfter);
}
parent::__construct($sql, static::ERROR_CODE_COLUMN_NOT_EXISTS);
}
示例4: __construct
public function __construct($table, $columns)
{
$changes = array();
foreach ($columns as $columnName => $columnType) {
$changes[] = sprintf("CHANGE `%s` `%s` %s", $columnName, $columnName, $columnType);
}
$sql = sprintf("ALTER TABLE `%s` %s", $table, implode(', ', $changes));
parent::__construct($sql, static::ERROR_CODE_UNKNOWN_COLUMN);
}
示例5: __construct
public function __construct($table, $columns, $placeColumnAfter)
{
$changes = array();
foreach ($columns as $columnName => $columnType) {
$part = sprintf("ADD COLUMN `%s` %s", $columnName, $columnType);
if (!empty($placeColumnAfter)) {
$part .= sprintf(' AFTER `%s`', $placeColumnAfter);
$placeColumnAfter = $columnName;
}
$changes[] = $part;
}
$sql = sprintf("ALTER TABLE `%s` %s", $table, implode(', ', $changes));
parent::__construct($sql, static::ERROR_CODE_DUPLICATE_COLUMN);
}
示例6: __construct
public function __construct()
{
parent::__construct();
}
示例7: __construct
/**
*
* @param string|boolean $tabela Define o nome da tabela. Caso não seja definido, usa o nome da classe como tabela
*/
public function __construct($tabela = FALSE)
{
parent::__construct();
$this->erros = array();
$this->mapaSql = $this->prepare = $this->consulta = array();
$this->dt_insert = $this->dt_update = Data::sqlAgora();
if (isset($_SESSION['usuario'])) {
$this->usuarioLogado = unserialize($_SESSION['usuario']);
$this->user_insert = $this->user_last_update = $this->usuarioLogado->get_idUsuario();
$this->tipo_usuario_insert = $this->tipo_usuario_update = $this->usuarioLogado->get_tipoUsuarioAtivo()->get_idTipoUsuario();
} else {
$this->usuarioLogado = null;
$this->user_insert = $this->user_last_update = 0;
}
$this->mapearVar('id', PDO::PARAM_INT, 11, TRUE)->mapearVar('user_insert', PDO::PARAM_INT)->mapearVar('tipo_usuario_insert', PDO::PARAM_INT)->mapearVar('user_last_update', PDO::PARAM_INT)->mapearVar('tipo_usuario_update', PDO::PARAM_INT)->mapearVar('dt_insert', PDO::PARAM_STR, 20, FALSE, 2)->mapearVar('dt_update', PDO::PARAM_STR, 20, FALSE, 2);
$this->tentativasCriar = 5;
$this->autoCriarTabelas = FALSE;
if (is_string($tabela)) {
$this->tabela = $tabela;
$this->setEsquema(substr($this->tabela, 0, strpos($this->tabela, ".")));
} else {
$this->autoEsquema()->setTabela();
}
}
示例8: __construct
public function __construct($table, $oldColumnName, $newColumnName, $columnType)
{
$sql = sprintf("ALTER TABLE `%s` CHANGE `%s` `%s` %s", $table, $oldColumnName, $newColumnName, $columnType);
parent::__construct($sql, array(static::ERROR_CODE_DUPLICATE_COLUMN, static::ERROR_CODE_UNKNOWN_COLUMN));
}
示例9: __construct
/**
* AddPrimaryKey constructor.
* @param string $table
* @param array $columnNames
*/
public function __construct($table, $columnNames)
{
$sql = sprintf("ALTER TABLE `%s` ADD PRIMARY KEY(`%s`)", $table, implode('`, `', $columnNames));
parent::__construct($sql, array(static::ERROR_CODE_DUPLICATE_KEY, static::ERROR_CODE_KEY_COLUMN_NOT_EXISTS));
}
示例10: __construct
public function __construct(\Gacela\Criteria $criteria = null)
{
$this->_operators['null'] = '=';
$this->_operators['notNull'] = '!=';
parent::__construct($criteria);
}
示例11: __construct
public function __construct()
{
parent::__construct();
$this->countTry = 10;
}