Download the PHP package darkterminal/gitlab-json-db without Composer
On this page you can find all versions of the php package darkterminal/gitlab-json-db. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darkterminal/gitlab-json-db
More information about darkterminal/gitlab-json-db
Files in darkterminal/gitlab-json-db
Package gitlab-json-db
Short Description A PHP Class that reads JSON file as a database. Use for sample DBs using Gitlab API inspire from donjajo/jsondb
License MIT
Informations about the package gitlab-json-db
GitlabDB
A PHP Class that reads JSON file as a database. Use for sample DBs using Gitlab API inspire from donjajo/php-jsondb
Usage
Install package
Initialize
Inserting
Insert into your new JSON file. Using users.json as example here
NB: Columns inserted first will be the only allowed column on other inserts
Get
Get back data, just like MySQL in PHP
All columns:
Custom Columns:
Where Statement:
This WHERE works as AND Operator at the moment or OR
Where Statement with regex:
By passingGitlabDB::regex
to where statement, you can apply regex searching. It can be used for implementing LIKE
or REGEXP_LIKE
clause in SQL.
Order By:
Thanks to Tarun Shanker for this feature. By passing the order_by()
method, the result is sorted with 2 arguments of the column name and sort method - GitlabDB::ASC
and GitlabDB::DESC
Updating Row
You can also update same JSON file with these methods
Without the where() method, it will update all rows
Deleting Row
Without the where() method, it will deletes all rows
Exporting to MySQL
You can export the JSON back to SQL file by using this method and providing an output
Disable CREATE TABLE
Exporting to XML
Tarun Shanker also provided a feature to export data to an XML file
<?php
if( $json_db->to_xml( 'users.json', 'users.xml' ) ) {
echo 'Saved!';
}