當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。