SQLite3 php

1.

Download SQLite3.exe from:  http://www.sqlite.org/download.html

sqlite-tools-win32-x86-3170000.zip

unzip, copy SQLite3 to: 

C:\xampp\htdocs\sqlite3.exe

2.

cmd>

Follow steps:
http://localhost/dashboard/docs/use-sqlite.html

cd C:\xampp\htdocs
sqlite3 mydb.sq3
CREATE TABLE items (id INTEGER PRIMARY KEY, name TEXT, price REAL);

 

INSERT INTO items VALUES ('1001', 'Salt', 3.15);
INSERT INTO items VALUES ('1002', 'Pepper', 2.75);
INSERT INTO items VALUES ('1003', 'Eggs', 2.00);
INSERT INTO items VALUES ('1004', 'Bacon', 7.25);
INSERT INTO items VALUES ('1005', 'Milk', 1.15);
INSERT INTO items VALUES ('1006', 'Strawberries', 8.73);
INSERT INTO items VALUES ('1007', 'Cereal', 2.65);
SELECT * FROM items;

 

<?php
$db = new SQLite3('mydb.sq3');
$sql = "SELECT * FROM items WHERE price < 3.00";
$result = $db->query($sql);
while ($row = $result->fetchArray(SQLITE3_ASSOC)){
  echo $row['name'] . ': $' . $row['price'] . '<br/>';
}
unset($db);

save as:  C:\xampp\htdocs\sqlite.php

3.

modify php.ini:

extension=php_pdo_sqlite.dll

extension=php_sqlite3.dll

restart Apache

4.

http://localhost/sqlite.php

Success !


got:

Pepper: $2.75

Eggs: $2

Milk: $1.15

Cereal: $2.65


5.

download:

SQLite Browser:  

http://sqlitebrowser.org/

install it,

use it open mydb.sq3 can see data in it !