This library and repository is no longer being maintained. Feel free, as always, to fork and make your own versions!
A fledged flat file database system. Driven by PHP. Stores data in JSON. SQL based data fetching.
Feel free to test it out somewhat on the demo page. When you create an account, the data is stored via the database on the server (I'm not sure how secure it is, so don't use a real password). When you log in, the data is retrieved from the database.
The awesomest part is that there are no running services, just pure PHP at work.
For a guide to all of the functions, use this wiki page.
Simply pull this git repository or download the archive and run it on a PHP-enabled server.
To access Fllat from any PHP file, require
the fllat.php
file:
require "fllat.php";
Now it's time to create and initialize a new database. This is used even if the database exists.
$pie = new Fllat("pie");
You can also use relative paths to direct Fllat to where the db.php
and database folder is:
require("../fllat.php");
$pie = new Fllat("pie", "../db");
Storing data into the database you created is easy! Just use one of the data-storing function provided:
Add a row to the database. Input an associative array in the form "column" => "data"
:
$yum = array("name" => "pepperoni", "size" => "large", "price" => "12.99");
$pie -> add($yum);
Rewrite the entire database table. Takes in an array of associative arrays (a list of rows) to overwrite the database:
$slurp = array("name" => "smoothie", "price" => "4.99");
$chomp = array("name" => "cookie", "price" => "2.99");
$nom = array("name" => "bacon", "price" => "0.00");
$pie -> rw(array($slurp, $chomp, $nom));
Fllat tries to use some simple and standard data retrieval methods, some of which are adapted from SQL. Here are the basics:
Input a column name, a column name, and a value, and it returns the value of the first column name where (in the same row), the value of the second column name matches the inputted value.
$pie -> get("price", "name", "bacon"); // Returns "0.00"
Returns some (or all) columns. Input an array of columns (empty array for all):
$pie -> select(array()); // Returns the whole thing (too long to list here)
$pie -> select(array("name")); // Returns [["smoothie"],["cookie"],["bacon"]]
Fllat is extremely flexibile. Perhaps too much so; it will json_encode
any data you give it and store it, regardless of what format it's in. This will cause some errors when retrieving data, so be careful!
Feel free to contribute by creating issues (search to see if the same issue has already been submitted beforehand) and submitting pull requests if you feel comfortable doing so.
Fllat is currently at version 0.1.0
.
Fllat is licensed for use under the terms stated in the LICENSE.md file.