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


PHP Statement::getPreparedStatement方法代码示例

本文整理汇总了PHP中Statement::getPreparedStatement方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::getPreparedStatement方法的具体用法?PHP Statement::getPreparedStatement怎么用?PHP Statement::getPreparedStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::getPreparedStatement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 /**
  * Perform upgrade for a table, by comparing one table to an old version
  * of the same table
  *
  * @param Table $old_table
  */
 public function upgrade(Table $old_table)
 {
     if ($old_table->getVersion() != $this->getVersion() - 1) {
         throw new Exception('Cannot upgrade from ' . get_class($old_table) . ' version ' . $old_table->getVersion() . ', must be version ' . ($this->getVersion() - 1));
     }
     $old_columns = $old_table->getColumns();
     $new_columns = $this->getColumns();
     $added_columns = \array_diff_key($new_columns, $old_columns);
     $altered_columns = Tools::array_diff_recursive($old_columns, $new_columns);
     $dropped_columns = \array_keys(array_diff_key($old_columns, $new_columns));
     $sqls = array();
     foreach ($added_columns as $column => $details) {
         $sqls[] = $this->_getAddColumnSQL($column, $details);
     }
     if (count($sqls)) {
         foreach ($sqls as $sqlStmt) {
             $statement = Statement::getPreparedStatement($sqlStmt);
             $res = $statement->performQuery('alter');
         }
     }
     $this->_migrateData($old_table);
     $sqls = array();
     foreach ($altered_columns as $column => $details) {
         if (in_array($column, $dropped_columns)) {
             continue;
         }
         $sqls[] = $this->_getAlterColumnSQL($old_columns[$column], $new_columns[$column]);
     }
     foreach ($dropped_columns as $details) {
         $sqls[] = $this->_getDropColumnSQL($details);
     }
     if (count($sqls)) {
         foreach ($sqls as $sqlStmt) {
             $statement = Statement::getPreparedStatement($sqlStmt);
             $res = $statement->performQuery('alter');
         }
     }
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:44,代码来源:Table.class.php

示例2: upgrade

 /**
  * Perform upgrade for a table, by comparing one table to an old version
  * of the same table
  *
  * @param Table $old_table
  */
 public function upgrade(Table $old_table)
 {
     $old_columns = $old_table->getColumns();
     $new_columns = $this->getColumns();
     $added_columns = \array_diff_key($new_columns, $old_columns);
     $altered_columns = Tools::array_diff_recursive($old_columns, $new_columns);
     $dropped_columns = \array_keys(array_diff_key($old_columns, $new_columns));
     $sqls = array();
     foreach ($added_columns as $details) {
         $sqls[] = $this->_getAddColumnSQL($details);
     }
     if (count($sqls)) {
         foreach ($sqls as $sqlStmt) {
             if ($sqlStmt) {
                 Statement::getPreparedStatement($sqlStmt)->performQuery();
             }
         }
     }
     $this->_migrateData($old_table);
     $sqls = array();
     foreach ($altered_columns as $column => $details) {
         if (in_array($column, $dropped_columns)) {
             continue;
         }
         $sqls[] = $this->_getAlterColumnSQL($new_columns[$column]);
         $altersql = $this->_getAlterColumnDefaultSQL($new_columns[$column]);
         if ($altersql) {
             $sqls[] = $altersql;
         }
     }
     foreach ($dropped_columns as $details) {
         $sqls[] = $this->_getDropColumnSQL($details);
     }
     if (count($sqls)) {
         foreach ($sqls as $sqlStmt) {
             if ($sqlStmt) {
                 Statement::getPreparedStatement($sqlStmt)->performQuery();
             }
         }
     }
 }
开发者ID:ellipsonic,项目名称:thebuggenige_app,代码行数:47,代码来源:Table.php


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