當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::exec方法代碼示例

本文整理匯總了PHP中Connection::exec方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::exec方法的具體用法?PHP Connection::exec怎麽用?PHP Connection::exec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Connection的用法示例。


在下文中一共展示了Connection::exec方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testExec

 public function testExec()
 {
     $that = $this;
     $this->connectAndAuth();
     $this->object->exec('uname -a', function ($stdio) use($that) {
         $that->assertInternalType('string', $stdio);
     });
 }
開發者ID:youknowriad,項目名稱:oossh,代碼行數:8,代碼來源:ConnectionTest.php

示例2: execute

 /**
  * @param null $sql
  *
  * @return mixed
  * @throws SqlException
  */
 public function execute($sql = null)
 {
     if (null == $sql) {
         $sql = $this->prepare();
     }
     $result = $this->_connection->exec($sql);
     if (false === $result) {
         throw new SqlException($this->_connection->getErrorMessage());
     }
     return $result;
 }
開發者ID:kendolabdev,項目名稱:kendoplatform,代碼行數:17,代碼來源:SqlDelete.php

示例3: __construct

 /**
  * Driver options:
  *   - charset => character encoding to set (default is utf8)
  *   - sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
  */
 public function __construct(Connection $connection, array $options)
 {
     $this->connection = $connection;
     $charset = isset($options['charset']) ? $options['charset'] : 'utf8';
     if ($charset) {
         $connection->exec("SET NAMES '{$charset}'");
     }
     if (isset($options['sqlmode'])) {
         $connection->exec("SET sql_mode='{$options['sqlmode']}'");
     }
     $connection->exec("SET time_zone='" . date('P') . "'");
 }
開發者ID:riskatlas,項目名稱:micka,代碼行數:17,代碼來源:MySqlDriver.php

示例4: connect

 /**
  * 鏈接數據庫
  * @param $config
  * @return Connection
  */
 public static function connect($config)
 {
     $dsn = $config['driver'] . ':host=' . $config['host'] . ';port=' . $config['port'];
     $user = $config['user'];
     $pass = $config['pass'];
     $connection_options = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
     $pdo = new Connection($dsn, $user, $pass, $connection_options);
     if (!empty($config['collation'])) {
         $pdo->exec('SET NAMES ' . $config['charset'] . ' COLLATE ' . $config['collation']);
     } else {
         $pdo->exec('SET NAMES ' . $config['charset']);
     }
     return $pdo;
 }
開發者ID:aeshion,項目名稱:ZeroPHP,代碼行數:19,代碼來源:Database.php

示例5: loadFromFile

 /**
  * Import SQL dump from file - extreme fast.
  * @return int  count of commands
  */
 public static function loadFromFile(Connection $connection, $file)
 {
     @set_time_limit(0);
     // intentionally @
     $handle = @fopen($file, 'r');
     // intentionally @
     if (!$handle) {
         throw new FileNotFoundException("Cannot open file '{$file}'.");
     }
     $count = 0;
     $sql = '';
     while (!feof($handle)) {
         $s = fgets($handle);
         $sql .= $s;
         if (substr(rtrim($s), -1) === ';') {
             $connection->exec($sql);
             // native query without logging
             $sql = '';
             $count++;
         }
     }
     if (trim($sql) !== '') {
         $connection->exec($sql);
         $count++;
     }
     fclose($handle);
     return $count;
 }
開發者ID:riskatlas,項目名稱:micka,代碼行數:32,代碼來源:Helpers.php


注:本文中的Connection::exec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。