本文整理汇总了PHP中Nette\Database\Connection::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::exec方法的具体用法?PHP Connection::exec怎么用?PHP Connection::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Connection
的用法示例。
在下文中一共展示了Connection::exec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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(Nette\Database\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') . "'");
}
示例2: loadFromFile
/**
* Import SQL dump from file - extreme fast.
* @param string filename
* @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 Nette\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++;
}
}
fclose($handle);
return $count;
}
示例3:
ERROR_DATA_TRUNCATED=1265;private$connection;function
__construct(Nette\Database\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')."'");}function
示例4: rollback
public function rollback()
{
$this->database->exec('ROLLBACK');
}