本文整理汇总了PHP中SQLite3::enableExceptions方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::enableExceptions方法的具体用法?PHP SQLite3::enableExceptions怎么用?PHP SQLite3::enableExceptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite3
的用法示例。
在下文中一共展示了SQLite3::enableExceptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Initialize the database for the registry
*
* Registry information that must be stored:
*
* - A list of installed packages
* - the files in each package
* - known channels
*/
function create(\SQLite3 $database)
{
$database->enableExceptions(true);
try {
$this->_create($database);
} catch (\Exception $e) {
$database->enableExceptions(false);
@$database->exec('ROLLBACK');
throw new \Pyrus\Registry\Exception('Cannot initialize SQLite3 registry: ' . $e->getMessage(), $e);
}
$database->enableExceptions(false);
}
示例2: getDirContents
<?php
if (!class_exists('SQLite3')) {
echo "install sqlite3 first, forexample: 'apt-get install php5-sqlite3'";
die("SQLite3 class not found!");
}
$params = array();
if (isset($argv)) {
$params = $argv;
}
$data = array();
$dir = "/var/www/src/grep";
$file = realpath(dirname(__FILE__)) . "/database.db";
// Open database
$db = new SQLite3($file);
$db->enableExceptions(true);
/* TOOL SCAN DIRECTORY AND GET ALL FILES */
function getDirContents($dir, &$results = array())
{
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = array('path' => $path, 'ext' => strtolower(pathinfo($path, PATHINFO_EXTENSION)), 'type' => "FILE");
} else {
if ($value != "." && $value != "..") {
$results[] = array('path' => $path, 'ext' => "", 'type' => "DIR");
getDirContents($path, $results);
}
}
}
示例3: catch
<?php
$db = new SQLite3(':memory:');
var_dump($db->enableExceptions(true));
try {
$db->query("SELECT * FROM non_existent_table");
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
var_dump($db->enableExceptions(false));
$db->query("SELECT * FROM non_existent_table");
var_dump($db->enableExceptions("wrong_type", "wrong_type"));
echo "Closing database\n";
var_dump($db->close());
echo "Done\n";