当前位置: 首页>>代码示例>>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;未经允许,请勿转载。