当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLite3::lastErrorCode方法代码示例

本文整理汇总了PHP中SQLite3::lastErrorCode方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::lastErrorCode方法的具体用法?PHP SQLite3::lastErrorCode怎么用?PHP SQLite3::lastErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite3的用法示例。


在下文中一共展示了SQLite3::lastErrorCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * The primary method a driver needs to implement is the execute method, which takes an array of query options.
  * The options in the array varies, but the key type will always be supplied, which will be either SELECT, UPDATE,
  * INSERT, REPLACE or DELETE.
  *
  * @param array $options An array of options that were generated through use of the Query class.
  * @return object It is expected to return an instance of an \Queryer\Driver\DatabaseDriverResult class.
  * @see \Queryer\Query, \Queryer\Driver\DatabaseDriverResult
  */
 public function execute(array $options)
 {
     $query = self::generateQuery($options);
     $query = DatabaseTools::replaceVariables($query, $options['variables']);
     $result = $this->sqlite->query($query);
     return new Sqlite3DriverResult($result, $this->sqlite->changes(), $this->sqlite->lastInsertRowID(), $result === false ? $this->sqlite->lastErrorCode() : null, $result === false ? $this->sqlite->lastErrorMsg() : null, $query);
 }
开发者ID:ianaldrighetti,项目名称:queryer,代码行数:16,代码来源:Sqlite3Driver.php

示例2: executeQuery

 /**
  * {@inheritdoc}
  */
 protected function executeQuery($query, array $parameters)
 {
     if (isset($this->statements[$query])) {
         $statement = $this->statements[$query];
     } else {
         // Temporary set the error reporting level to 0 to avoid any warning.
         $errorReportingLevel = error_reporting(0);
         $statement = $this->sqlite3->prepare($query);
         // Restore the original error reporting level.
         error_reporting($errorReportingLevel);
         $errorCode = $this->sqlite3->lastErrorCode();
         if ($errorCode !== 0) {
             $exception = new SQLite3Exception($this->sqlite3->lastErrorMsg(), $errorCode);
             if ($errorCode === 1) {
                 // SQL error cause by a missing function, this must be reported with a GeometryEngineException.
                 throw GeometryEngineException::operationNotSupportedByEngine($exception);
             } else {
                 // Other SQLite3 error; we cannot trigger the original E_WARNING, so we throw this exception instead.
                 throw $exception;
             }
         } else {
             $this->statements[$query] = $statement;
         }
     }
     $index = 1;
     foreach ($parameters as $parameter) {
         if ($parameter instanceof Geometry) {
             if ($parameter->isEmpty()) {
                 $statement->bindValue($index++, $parameter->asText(), SQLITE3_TEXT);
                 $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER);
             } else {
                 $statement->bindValue($index++, $parameter->asBinary(), SQLITE3_BLOB);
                 $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER);
             }
         } else {
             if ($parameter === null) {
                 $type = SQLITE3_NULL;
             } elseif (is_int($parameter)) {
                 $type = SQLITE3_INTEGER;
             } elseif (is_float($parameter)) {
                 $type = SQLITE3_FLOAT;
             } else {
                 $type = SQLITE3_TEXT;
             }
             $statement->bindValue($index++, $parameter, $type);
         }
     }
     $result = $statement->execute();
     return $result->fetchArray(SQLITE3_NUM);
 }
开发者ID:brick,项目名称:geo,代码行数:53,代码来源:SQLite3Engine.php

示例3: connect

 /**
  * Establishes a connection to the defined database.
  *
  * @return void
  */
 public function connect()
 {
     if ($this->connected === TRUE) {
         return;
     }
     if ($this->configuration['db']['driver'] != 'sqlite3') {
         $this->logger->error('Cannot connect to a non-sqlite3 database connection!');
         return;
     }
     $flag = $this->readonly ? SQLITE3_OPEN_READONLY : SQLITE3_OPEN_READWRITE;
     $this->sqlite3->open($this->db, $flag | SQLITE3_OPEN_CREATE, '');
     if ($this->sqlite3->lastErrorCode() === 0) {
         $this->connected = TRUE;
     }
 }
开发者ID:rubendgr,项目名称:lunr,代码行数:20,代码来源:SQLite3Connection.php

示例4: __construct

 /**
  * @param string          $dbname database name
  * @param OutputInterface $output standard verbode output
  * @param boolean         $renew  if true delete and recreate database
  *
  * @throws \Exception
  */
 public function __construct($dbname, OutputInterface $output, $renew = false)
 {
     $this->fs = new Filesystem();
     $this->output = $output;
     $this->dbname = $dbname;
     if ($renew) {
         if ($this->fs->exists($this->dbname)) {
             $this->fs->remove($this->dbname);
         }
     }
     $this->db = new \SQLite3($this->dbname);
     if ($this->db->exec('PRAGMA encoding = "UTF-8";') === false) {
         $this->output->writeln($this->db->lastErrorCode() . " : " . $this->db->lastErrorMsg());
         throw new \Exception("cannot set encoding UTF-8");
     }
 }
开发者ID:emmanuelroecker,项目名称:js-php-real-time-search,代码行数:23,代码来源:GlServerEngine.php

示例5: error

 /**
  * Returns the error string.
  *
  * @return string
  */
 public function error()
 {
     if (0 === $this->conn->lastErrorCode()) {
         return '';
     }
     return $this->conn->lastErrorMsg();
 }
开发者ID:atlcurling,项目名称:tkt,代码行数:12,代码来源:Sqlite3.php

示例6: __construct

    /**
     * @param string $databaseFilename
     */
    public function __construct($databaseFilename, $tableName = 'events')
    {
        $databaseFilename = strval($databaseFilename);
        $tableName = strval($tableName);
        $this->_tableName = $tableName;
        $this->_databaseHandle = new SQLite3($databaseFilename);
        if ($this->_databaseHandle->lastErrorCode() != 0) {
            throw new Exception('Unable to connect to DB.');
        }
        $this->_databaseHandle->exec(<<<EOT
            CREATE TABLE IF NOT EXISTS {$tableName} (
                id INTEGER PRIMARY KEY,
                headers STRING,
                body STRING
            )
EOT
);
    }
开发者ID:arwhyte,项目名称:viadutoo,代码行数:21,代码来源:SQLite3Storage.php

示例7: execute

 function execute($query)
 {
     if (!$this->isConnected()) {
         throw new NotConnectedException();
     }
     Connection::startMeasuring($this);
     if (func_num_args() > 1) {
         $query = call_user_func_array('sprintf', func_get_args());
     }
     $result = $this->connection->query($query);
     Connection::endMeasuring($this);
     if (!$result) {
         throw new QueryException($this->connection->lastErrorMsg(), $this->connection->lastErrorCode());
     }
     if ($result instanceof \SQLite3Result) {
         return new RecordSet($result);
     }
     return $result;
 }
开发者ID:maniaplanet,项目名称:manialive-lib,代码行数:19,代码来源:Connection.php

示例8: testError

 /**
  * Test if a error exist, if yes than throw error
  *
  * @throws CHOQ_Exception
  * @param string $query
  */
 public function testError($query = null)
 {
     if ($this->sqlite->lastErrorCode()) {
         $error = $this->sqlite->lastErrorMsg();
         if ($query) {
             $error .= "\nSQL Query: {$query}";
         }
         error($error);
     }
 }
开发者ID:nonconforme,项目名称:nreeda,代码行数:16,代码来源:Sqlite3.class.php

示例9: checkError

 /**
  * Checks the last error code and decide if and what kind of exception to throw.
  * @return true if nothing is wrong
  * @throws CoreXEngine\Cache\AccessException if we want to write a read-only file
  * @throws CoreXEngine\Cache\Exception for no special typed problem
  */
 protected function checkError()
 {
     switch ($code = $this->database->lastErrorCode()) {
         case 8:
             throw new AccessException($this->database->lastErrorMsg(), $this->database->lastErrorCode());
             break;
         default:
             if (0 < $code) {
                 throw new Exception($this->database->lastErrorMsg(), $this->database->lastErrorCode());
             }
     }
     return true;
 }
开发者ID:anthraxx,项目名称:CoreXEngine,代码行数:19,代码来源:SQLite.php

示例10: create_table_if_not_exist

 public function create_table_if_not_exist($tablename, $fieldsdefinition)
 {
     // check if tablename is already present
     $check = @parent::querySingle("SELECT count(*) FROM {$tablename}");
     $code = @parent::lastErrorCode();
     if (0 < $check || 0 == $check && 0 == $code) {
         return true;
     } else {
         $sql = "CREATE TABLE {$tablename} ({$fieldsdefinition})";
         $res = $this->exec($sql);
         return $res !== false ? true : false;
     }
 }
开发者ID:horst-n,项目名称:WireQueue,代码行数:13,代码来源:WireQueueLibHnSqlite3.php

示例11: query

 /**
  * Execute the SQL query.
  *
  * @param  string $sql
  * @throws Exception
  * @return void
  */
 public function query($sql)
 {
     if ($this->isPdo) {
         $sth = $this->sqlite->prepare($sql);
         if (!$sth->execute()) {
             throw new Exception($sth->errorCode() . ': ' . $sth->errorInfo());
         } else {
             $this->result = $sth;
         }
     } else {
         if (!($this->result = $this->sqlite->query($sql))) {
             throw new Exception('Error: ' . $this->sqlite->lastErrorCode() . ': ' . $this->sqlite->lastErrorMsg() . '.');
         }
     }
 }
开发者ID:popphp,项目名称:pop-cache,代码行数:22,代码来源:Sqlite.php

示例12: execute

 /**
  * Wykonanie zapytania bazy danych
  *
  * @param string $query
  * @return \SQLite3Result
  * @throws Exception
  */
 public function execute($query)
 {
     if (!$this->connected) {
         $this->connect();
     }
     if ($this->dbHandle == null) {
         return false;
     }
     $this->queryCount += 1;
     $tResult = $this->dbHandle->query($query);
     if (!$tResult) {
         throw new Exception($this->dbHandle->lastErrorMsg(), $this->dbHandle->lastErrorCode());
     }
     /**
      * logowanie zapytań do pliku
      */
     if ($this->writeToFile) {
         $this->writeLog($query);
     }
     return $tResult;
 }
开发者ID:PhanQuocTrung,项目名称:WeatherStation,代码行数:28,代码来源:SQLiteWrapper.php

示例13: import

 /**
  * @param int      $id
  * @param array    $data
  * @param callable $callback
  *
  * @throws \Exception
  */
 public function import(&$id, array $data, callable $callback)
 {
     foreach ($data as $uid => $elem) {
         $valuesFullText = $this->valuesFullText($elem);
         $valuesFilter = $this->valuesFilter($elem);
         if (sizeof($valuesFullText) > 0) {
             $json = json_encode($elem);
             $num = 1;
             $this->stmtInsertFilter->bindValue($num++, $id, SQLITE3_INTEGER);
             if ($this->useuid) {
                 $this->stmtInsertFilter->bindValue($num++, $uid, SQLITE3_TEXT);
             }
             $this->stmtInsertFilter->bindValue($num++, $json, SQLITE3_TEXT);
             foreach ($valuesFilter as $valueFilter) {
                 $this->stmtInsertFilter->bindValue($num++, $valueFilter);
             }
             if (@$this->stmtInsertFilter->execute() === false) {
                 $lasterror = $this->db->lastErrorCode();
                 if ($lasterror != self::SQLITE_ERROR_CODE_CONSTRAINT) {
                     $this->output->writeln($lasterror . " : " . $this->db->lastErrorMsg());
                     throw new \Exception("cannot insert filter fields");
                 } else {
                     @$this->stmtInsertFilter->reset();
                     continue;
                 }
             }
             $num = 1;
             $this->stmtInsertFullText->bindValue($num++, $id, SQLITE3_INTEGER);
             foreach ($valuesFullText as $valueFullText) {
                 $this->stmtInsertFullText->bindValue($num++, $valueFullText, SQLITE3_TEXT);
             }
             if ($this->stmtInsertFullText->execute() === false) {
                 $this->output->writeln($this->db->lastErrorCode() . " : " . $this->db->lastErrorMsg());
                 throw new \Exception("cannot insert full text fields");
             }
             $id++;
         }
         $callback();
     }
 }
开发者ID:emmanuelroecker,项目名称:js-php-real-time-search,代码行数:47,代码来源:GlServerIndex.php

示例14: errorCode

 public function errorCode()
 {
     return $this->handler->lastErrorCode();
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:4,代码来源:waDbSqlite3Adapter.class.php

示例15: open

 /**
  * function to establish a database connection
  *
  * @return bool
  * @throws \RuntimeException if something went wrong establishing the connection
  */
 public function open()
 {
     $conn = new \SQLite3($this->path, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password);
     if ($conn->lastErrorCode()) {
         throw new \RuntimeException('Failed to connect: #' . $conn->lastErrorCode() . ' | ' . $conn->lastErrorMsg());
     }
     $this->conn = $conn;
     $this->status = 'open';
     return true;
 }
开发者ID:BlackyPanther,项目名称:SQL-Class,代码行数:16,代码来源:SQL.class.php


注:本文中的SQLite3::lastErrorCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。