本文整理汇总了PHP中sqlite_error_string函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_error_string函数的具体用法?PHP sqlite_error_string怎么用?PHP sqlite_error_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_error_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Tests that the storage location is a directory and is writable.
*/
public function __construct($filename)
{
// Get the directory name
$directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
// Set the filename from the real directory path
$filename = $directory . basename($filename);
// Make sure the cache directory is writable
if (!is_dir($directory) or !is_writable($directory)) {
throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory));
}
// Make sure the cache database is writable
if (is_file($filename) and !is_writable($filename)) {
throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename));
}
// Open up an instance of the database
$this->db = new SQLiteDatabase($filename, '0666', $error);
// Throw an exception if there's an error
if (!empty($error)) {
throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
}
$query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
$tables = $this->db->query($query, SQLITE_BOTH, $error);
// Throw an exception if there's an error
if (!empty($error)) {
throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
}
if ($tables->numRows() == 0) {
// Issue a CREATE TABLE command
$this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);');
}
}
示例2: _catch
function _catch($msg = "")
{
if (!($this->error = sqlite_error_string(sqlite_last_error($this->conn)))) {
return true;
}
$this->error($msg . "<br>{$this->query}\n {$this->error}");
}
示例3: __construct
/**
* Tests that the storage location is a directory and is writable.
*/
public function __construct($filename)
{
// Get the directory name
$directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
// Set the filename from the real directory path
$filename = $directory . basename($filename);
// Make sure the cache directory is writable
if (!is_dir($directory) or !is_writable($directory)) {
throw new Kohana_Exception('cache.unwritable', $directory);
}
// Make sure the cache database is writable
if (is_file($filename) and !is_writable($filename)) {
throw new Kohana_Exception('cache.unwritable', $filename);
}
// Open up an instance of the database
$this->db = new SQLiteDatabase($filename, '0666', $error);
// Throw an exception if there's an error
if (!empty($error)) {
throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error));
}
$query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
$tables = $this->db->query($query, SQLITE_BOTH, $error);
// Throw an exception if there's an error
if (!empty($error)) {
throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error));
}
if ($tables->numRows() == 0) {
Kohana::log('error', 'Cache: Initializing new SQLite cache database');
// Issue a CREATE TABLE command
$this->db->unbufferedQuery(Kohana::config('cache_sqlite.schema'));
}
}
示例4: composeReader
protected function composeReader($o)
{
if (!($db = $this->getDb($o))) {
return $o;
}
if ($sql = $this->get->sql) {
$o->read_sql = pStudio_highlighter::highlight($sql, 'sql', false);
if (self::isReadOnlyQuery($db, $sql, $o->error_msg)) {
$sql = "{$sql}\n LIMIT {$this->get->start}, {$this->get->length}";
$rows = @$db->arrayQuery($sql, SQLITE_ASSOC);
if (false !== $rows) {
if ($rows) {
$o->fields = new loop_array(array_keys($rows[0]));
$o->rows = new loop_array($rows, array($this, 'filterRow'));
$o->start = $this->get->start;
$o->length = $this->get->length;
}
} else {
$o->error_msg = sqlite_error_string($db->lastError());
}
}
} else {
$sql = "SELECT name, type\n FROM sqlite_master\n WHERE type IN ('table', 'view')\n ORDER BY name";
$tables = $db->arrayQuery($sql, SQLITE_ASSOC);
$o->tables = new loop_array($tables, 'filter_rawArray');
if (!$o->is_auth_edit) {
$f = new pForm($o, '', false);
$f->setPrefix('');
$f->add('hidden', 'low');
$f->add('hidden', 'high');
$f->add('textarea', 'sql');
}
}
return $o;
}
示例5: _doExec
protected function _doExec($query)
{
if ($qI = sqlite_query($query, $this->_connection)) {
return sqlite_changes($this->_connection);
} else {
throw new jException('jelix~db.error.query.bad', sqlite_error_string($this->_connection) . '(' . $query . ')');
}
}
示例6: real_execute_sql
public function real_execute_sql($sql)
{
$result_set_handle = sqlite_query($this->connection_handle, $sql);
if (!$result_set_handle) {
throw new AnewtDatabaseQueryException('SQLite error: %s', sqlite_error_string(sqlite_last_error($this->connection_handle)));
}
return new AnewtDatabaseResultSetSQLite($sql, $this->connection_handle, $result_set_handle);
}
示例7: _set_stmt_error
protected function _set_stmt_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
{
$errno = sqlite_last_error($this->_link);
if ($state === null) {
$state = 'HY000';
}
$this->_set_error($errno, sqlite_error_string($errno), $state, $mode, $func);
}
示例8: SqliteResultSet
/**
* Constructs a new SqliteResultSet
*
* \param $sql
* The sql query to execute.
*
* \param $backend
* A reference to the used backend.
*/
function SqliteResultSet($sql, &$backend)
{
assert('is_string($sql)');
$this->sql = $sql;
$this->backend =& $backend;
$this->rs = sqlite_query($this->backend->handle, $sql) or trigger_error(sprintf('Query failed (%s)', sqlite_error_string(sqlite_last_error($this->backend->handle))), E_USER_ERROR);
$this->rows_affected = sqlite_changes($this->backend->handle);
}
示例9: query
public function query($sql)
{
LogMaster::log($sql);
$res = sqlite_query($this->connection, $sql);
if ($res === false) {
throw new Exception("SQLLite - sql execution failed\n" . sqlite_error_string(sqlite_last_error($this->connection)));
}
return $res;
}
示例10: query
/**
* query
*
* @param mixed $query
* @access public
* @return mixed
* @throws AdapterException
*/
public function query($query)
{
$handle = @sqlite_query($query, $this->_dbHandle);
if (!$handle) {
$errorCode = sqlite_last_error($this->_dbHandle);
throw new AdapterException(sqlite_error_string($errorCode), $errorCode);
}
return $handle;
}
示例11: _error_handler
function _error_handler(array $errarray, $query = '')
{
$err = sprintf('%s on line %d.', $errarray[0], $errarray[1]);
$errno = sqlite_last_error($this->con);
if (defined('DEBUG') && DEBUG) {
$err .= sprintf(PHP_EOL . "Description: #%d: %s" . PHP_EOL . "SQL: %s", $errno, sqlite_error_string($errno), $query);
}
throw new RuntimeException($err, $errno);
}
示例12: query
/**
* 执行数据库查询
*
* @param string $query
* @param mixed $handle
* @param int $op
* @param null $action
* @return resource|SQLiteResult
* @throws Typecho_Db_Query_Exception
*/
public function query($query, $handle, $op = Typecho_Db::READ, $action = NULL)
{
if ($resource = @sqlite_query($query instanceof Typecho_Db_Query ? $query->__toString() : $query, $handle)) {
return $resource;
}
/** 数据库异常 */
$errorCode = sqlite_last_error($this->_dbHandle);
throw new Typecho_Db_Query_Exception(sqlite_error_string($errorCode), $errorCode);
}
示例13: safe_query
function safe_query($query)
{
$res = sqlite_query($query, sqlite_r);
if (!$res) {
$err_code = sqlite_last_error(sqlite_r);
printf("Query Failed %d:%s\n", $err_code, sqlite_error_string($err_code));
exit;
}
return $res;
}
示例14: __construct
/**
* This function initializes the class.
*
* @access public
* @override
* @param DB_Connection_Driver $connection the connection to be used
* @param string $sql the SQL statement to be queried
* @param integer $mode the execution mode to be used
* @throws Throwable_SQL_Exception indicates that the query failed
*/
public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL)
{
$resource = $connection->get_resource();
$command = @sqlite_query($resource, $sql);
if ($command === FALSE) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => sqlite_error_string(sqlite_last_error($resource))));
}
$this->command = $command;
$this->record = FALSE;
}
示例15: query
function query($sql)
{
global $page;
if (!($this->result = sqlite_query($this->dbres, $sql))) {
print "Query failed, <span style=\"color: blue;\"><pre>{$sql}</pre></style>\n";
print sqlite_error_string(sqlite_last_error($this->dbres));
$page->footer();
exit;
}
}