当前位置: 首页>>代码示例>>PHP>>正文


PHP Sql::__construct方法代码示例

本文整理汇总了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));
 }
开发者ID:piwik,项目名称:piwik,代码行数:31,代码来源:AddIndex.php

示例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);
 }
开发者ID:piwik,项目名称:piwik,代码行数:8,代码来源:AddColumn.php

示例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);
 }
开发者ID:piwik,项目名称:piwik,代码行数:8,代码来源:DropColumn.php

示例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);
 }
开发者ID:piwik,项目名称:piwik,代码行数:9,代码来源:ChangeColumnTypes.php

示例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);
 }
开发者ID:piwik,项目名称:piwik,代码行数:14,代码来源:AddColumns.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
 }
开发者ID:andersongimino,项目名称:area51,代码行数:4,代码来源:SqlNewsAdmin.php

示例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();
     }
 }
开发者ID:andersongimino,项目名称:area51,代码行数:28,代码来源:ModelBase.php

示例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));
 }
开发者ID:piwik,项目名称:piwik,代码行数:5,代码来源:ChangeColumn.php

示例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));
 }
开发者ID:piwik,项目名称:piwik,代码行数:10,代码来源:AddPrimaryKey.php

示例10: __construct

 public function __construct(\Gacela\Criteria $criteria = null)
 {
     $this->_operators['null'] = '=';
     $this->_operators['notNull'] = '!=';
     parent::__construct($criteria);
 }
开发者ID:energylab,项目名称:gacela,代码行数:6,代码来源:Soql.php

示例11: __construct

 public function __construct()
 {
     parent::__construct();
     $this->countTry = 10;
 }
开发者ID:andersongimino,项目名称:area51,代码行数:5,代码来源:UsoSap.php


注:本文中的Sql::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。