Browse Source

Initial implementation SQLite

Maurits van der Schee 9 years ago
parent
commit
908cb0ce91
3 changed files with 31 additions and 7 deletions
  1. 20
    4
      README.md
  2. 8
    0
      api.php
  3. 3
    3
      tests/config.php.dist

+ 20
- 4
README.md View File

@@ -3,13 +3,12 @@
3 3
 
4 4
 # PHP_CRUD_API
5 5
 
6
-Single file PHP script that adds a REST API to a MySQL InnoDB database. Alternatively both PostgreSQL 9 and MS SQL Server 2012 are fully supported.
6
+Single file PHP script that adds a REST API to a MySQL InnoDB database. Alternatively both SQLite 3, PostgreSQL 9 and MS SQL Server 2012 are fully supported.
7 7
 
8 8
 ## Requirements
9 9
 
10
-  - PHP 5.3 or higher with MySQLi, libpq or SQLSRV enabled
10
+  - PHP 5.3 or higher with MySQLi, libpq, SQLSRV or sqlite3 enabled
11 11
   - PHP on Windows when connecting to SQL Server 2012
12
-  - PostgreSQL 9 or higher when connecting to PostgreSQL
13 12
 
14 13
 ## Installation
15 14
 
@@ -86,7 +85,7 @@ $api = new PHP_CRUD_API(array(
86 85
 $api->executeCommand();
87 86
 ```
88 87
 
89
-NB: The "socket" option is not supported by MS SQL Server.
88
+NB: The "socket" option is not supported by MS SQL Server. SQLite expects the filename in the "database" field.
90 89
 
91 90
 ## Documentation
92 91
 
@@ -631,6 +630,23 @@ $
631 630
 
632 631
 NB: You MUST use an empty database as a desctructive database fixture ('blog_postgresql.sql') is loaded.
633 632
 
633
+### SQLite on Linux
634
+
635
+```
636
+$ wget https://phar.phpunit.de/phpunit.phar
637
+$ php phpunit.phar tests/tests.php
638
+PHPUnit 5.1.3 by Sebastian Bergmann and contributors.
639
+
640
+.............................................                     45 / 45 (100%)
641
+
642
+Time: 1.84 seconds, Memory: 11.25Mb
643
+
644
+OK (45 tests, 69 assertions)
645
+$
646
+```
647
+
648
+NB: You MUST use an empty database as a desctructive database fixture ('blog_sqlite.sql') is loaded.
649
+
634 650
 ## Pretty URL
635 651
 
636 652
 You may "rewrite" the URL to remove the "api.php" from the URL.

+ 8
- 0
api.php View File

@@ -1874,3 +1874,11 @@ class PHP_CRUD_API {
1874 1874
 // 	'charset'=>'UTF8'
1875 1875
 // ));
1876 1876
 // $api->executeCommand();
1877
+
1878
+// For SQLite 3 use:
1879
+
1880
+// $api = new PHP_CRUD_API(array(
1881
+// 	'dbengine'=>'SQLite',
1882
+// 	'database'=>'xxx',
1883
+// ));
1884
+// $api->executeCommand();

+ 3
- 3
tests/config.php.dist View File

@@ -3,8 +3,8 @@
3 3
 class PHP_CRUD_API_Config
4 4
 {
5 5
 	public static $dbengine='MySQL';             // 'MySQL', 'SQLServer', 'PostgreSQL' or 'SQLite'
6
-	public static $hostname='{{test_hostname}}'; // 'localhost' for mysql or '(Local)' for mssql
7
-	public static $username='{{test_username}}'; // May be empty on mssql
8
-	public static $password='{{test_password}}'; // May be empty on mssql
6
+	public static $hostname='{{test_hostname}}'; // 'localhost' for MySQL, '(Local)' for SQLServer, empty for SQLite
7
+	public static $username='{{test_username}}'; // May be empty on SQLServer or SQLite
8
+	public static $password='{{test_password}}'; // May be empty on SQLServer or SQLite
9 9
 	public static $database='{{test_database}}'; // NB: Use an empty database, data will be LOST!
10 10
 }

Loading…
Cancel
Save