Home  >  Article  >  Backend Development  >  PHP reads sqlite entry example

PHP reads sqlite entry example

WBOY
WBOYOriginal
2016-07-25 09:12:151371browse

Example, php reads sqlite data.

  1. //Open sqlite database

  2. //$db = @sqlite_open("MM.sqlite", 0666, $error); // Not supported
  3. //$ db = new PDO('sqlite:MM.sqlite');
  4. //Exception handling
  5. if (!$db) die("Connection Sqlite failed.n");

  6. //Add A database called foo

  7. //@sqlite_query($db, "CREATE TABLE foo (bar varchar(10))");
  8. //Insert a record
  9. //@sqlite_query($db, "INSERT INTO foo VALUES (' fnord')");

  10. //Retrieve all records

  11. $result = $db->query('select BottleEncryptUsrName from BottleTable4');

  12. //Print the obtained results

  13. foreach($result as $row){
  14. echo $row[0];
  15. echo "
    ";
  16. }
  17. ?>

Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn