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

PHP reads sqlite entry example

WBOY
Release: 2016-07-25 09:12:15
Original
1402 people have browsed it

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template