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


PHP CDbConnection::quoteTableName方法代码示例

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


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

示例1: run

 public function run($sArgument)
 {
     if (!isset($sArgument) || !isset($sArgument[0]) || !isset($sArgument[1]) || !isset($sArgument[2]) || !isset($sArgument[3])) {
         die('You have to set admin/password/full name and email address on the command line like this: php starter.php adminname mypassword fullname emailaddress');
     }
     Yii::import('application.helpers.common_helper', true);
     try {
         $this->connection = App()->getDb();
         $this->connection->active = true;
     } catch (CDbException $e) {
         $this->createDatabase();
     }
     $this->connection->charset = 'utf8';
     switch ($this->connection->driverName) {
         case 'mysql':
         case 'mysqli':
             $this->connection->createCommand("ALTER DATABASE " . $this->connection->quoteTableName($this->getDBConnectionStringProperty('dbname')) . " DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
             $sql_file = 'mysql';
             break;
         case 'pgsql':
             $sql_file = 'pgsql';
             break;
         case 'dblib':
         case 'mssql':
         case 'sqlsrv':
             $sql_file = 'mssql';
             break;
         default:
             throw new Exception(sprintf('Unknown database type "%s".', $this->connection->driverName));
     }
     $this->_executeSQLFile(dirname(Yii::app()->basePath) . '/installer/sql/create-' . $sql_file . '.sql');
     $this->connection->createCommand()->insert($this->connection->tablePrefix . 'users', array('users_name' => $sArgument[0], 'password' => hash('sha256', $sArgument[1]), 'full_name' => $sArgument[2], 'parent_id' => 0, 'lang' => 'auto', 'email' => $sArgument[3]));
     $this->connection->createCommand()->insert($this->connection->tablePrefix . 'permissions', array('entity' => 'global', 'entity_id' => 0, 'uid' => 1, 'permission' => 'superadmin', 'create_p' => 0, 'read_p' => 1, 'update_p' => 0, 'delete_p' => 0, 'import_p' => 0, 'export_p' => 0));
 }
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:34,代码来源:InstallCommand.php

示例2: testCreateDb

 public function testCreateDb()
 {
     $step1 = new Step1();
     $step1->setAttributes($this->data, false);
     $this->assertTrue($step1->createDb());
     $conn_string = 'mysql:host=' . $step1->db_host . ';dbname=' . $step1->db_name;
     $con = new CDbConnection($conn_string, $step1->db_login, $step1->db_pass);
     try {
         $con->init();
     } catch (Exception $e) {
         $this->assert('Db was not created');
     }
     $con->createCommand('DROP DATABASE IF EXISTS ' . $con->quoteTableName($this->data['db_name']))->execute();
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:14,代码来源:Step1Test.php

示例3: array

 /**
  * Installer::_setup_tables()
  * Function that actually modify the database. Read $sqlfile and execute it.
  * @param string $sqlfile
  * @return  Empty string if everything was okay - otherwise the error messages
  */
 function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
 {
     extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
     try {
         switch ($sDatabaseType) {
             case 'mysql':
             case 'mysqli':
                 $this->connection->createCommand("ALTER DATABASE " . $this->connection->quoteTableName($sDatabaseName) . " DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
                 break;
         }
     } catch (Exception $e) {
         return array($e->getMessage());
     }
     return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
 }
开发者ID:Narasimman,项目名称:UrbanExpansion,代码行数:21,代码来源:InstallerController.php

示例4: array

 /**
  * Installer::_setup_tables()
  * Function that actually modify the database. Read $sqlfile and execute it.
  * @param string $sqlfile
  * @return  Empty string if everything was okay - otherwise the error messages
  */
 function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
 {
     extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
     switch ($sDatabaseType) {
         case 'mysql':
         case 'mysqli':
             $this->connection->createCommand("ALTER DATABASE " . $this->connection->quoteTableName($sDatabaseName) . " DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
             break;
         case 'pgsql':
             if (version_compare($this->connection->getServerVersion(), '9', '>=')) {
                 $this->connection->createCommand("ALTER DATABASE " . $this->connection->quoteTableName($sDatabaseName) . " SET bytea_output='escape';")->execute();
             }
             break;
     }
     return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
 }
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:22,代码来源:InstallerController.php


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