Download the PHP package muhammetsafak/jsonbase without Composer
On this page you can find all versions of the php package muhammetsafak/jsonbase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download muhammetsafak/jsonbase
More information about muhammetsafak/jsonbase
Files in muhammetsafak/jsonbase
Package jsonbase
Short Description It is a library that allows to use JSon files as database.
License MIT
Homepage https://github.com/muhammetsafak/jsonbase
Informations about the package jsonbase
JSONBase
It is a library that allows to use JSON files as database.
Note : Do not use this library for big data. This library is suitable for use only for very small data.
Requirements
- PHP 7.4 or higher
- PHP JSON Extension
Installation
Include the JSonBase.php file and let it know in which directory to keep the JSon files.
Usage
Table Create
For JsonBase, each table is actually a .json
file.
Definition of create_table()
method:
Insert
Definition of insert()
method
Multi Insert
Definition of multiInsert()
method
This method may throw an error if $data is not a multi-array.
Update
Definition of update()
method
Delete
Definition of delete()
method
DROP
It tries to completely delete the table and its contents.
Definition of drop()
method
Example
TRUNCATE
Empties all data in a table by deleting it.
Example
Rename
Changes the name of a table.
Example
Copy
Allows a table to be copied along with its data.
Caution: If there is a different table with the table name to be copied, it will overwrite (delete) it to avoid conflicts.
Example
Donwload
It allows you to download the JSonBase file. This method will try to initiate a download via the browser by adding a timestamp to the filename along with its contents.
Example
It stops the PHP script after it. It does nothing if the requested table does not exist.
Tables
Returns the loaded table names as an array.
Example
produces a similar output:
Size
Returns the total size of the table in bytes.
Example
produces a similar output:
rowSize
Returns the total number of rows in the table.
Example
produces a similar output:
QUERY BUILD
You can use the select()
, from()
and where()
methods to create a query in the JSonBase library.
select()
It is used to generate a Json query. Specifies the columns in the results from the row()
and rows()
methods. *
means all columns. If more than one column is desired, they must be separated by ,
.
Definition of select()
method
from()
It is used to generate a Json query. Indicates on which Json the query to be executed with get()
method will be executed.
Definition of from()
method
$from
a table name.
where()
It is used to generate a Json query. Creates a where array for the query to be executed with the get()
method. Multiple matches can be made using this method chaining.
Definition of where()
method
$key
a column name
$value
value in column
Multiple where can be added using the where()
method multiple times in a row or chaining.
The query constructed with the from()
and where()
methods should be executed with the get()
method.
get()
Execute the query created with the select()
, from()
and where()
methods and get the results if any. You can access the results obtained with this method with the row()
, rows()
methods.
Definition of get()
method
Results
You can access the results obtained by executing the get()
method with the row()
, rows()
methods.
row()
Returns the first result obtained as an associative array.
Definition of row()
method
rows()
Returns the resulting results as an associative array.
Definition of rows()
method
Num_Rows
_num_rows()
_ Returns the number of rows affected.
Definition of num_rows()
method
Examples
Suppose we have a students.json
file like the one below.
Example 1 :
Output:
Example 2 :
Output:
Example 3 :
Output:
Getting Help
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
Getting Involved
All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.
There are two primary ways to help:
- Using the issue tracker, and
- Changing the code-base.
Using the issue tracker
Use the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution.
Use the issue tracker to find ways to contribute. Find a bug or a feature, mention in the issue that you will take on that effort, then follow the Changing the code-base guidance below.
Changing the code-base
Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All new code should have associated unit tests that validate implemented features and the presence or lack of defects. Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing code-base.
Credits
License
Copyright © 2022 MIT License
All versions of jsonbase with dependencies
ext-json Version *