GithubHelp home page GithubHelp logo

anthrax3 / fllat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mungell/fllat

0.0 1.0 0.0 476 KB

A flat file database system. Driven by PHP. Stores data in JSON. SQL based data fetching.

Home Page: fllat.lfred.info/fllat

License: Other

PHP 100.00%

fllat's Introduction

Fllat

A fledged flat file database system. Driven by PHP. Stores data in JSON. SQL based data fetching.

Introduction

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.

Documentation

For a guide to all of the functions, use this wiki page.

Getting started

Simply pull this git repository or download the archive and run it on a PHP-enabled server.

Accessing Fllat

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

Storing data into the database you created is easy! Just use one of the data-storing function provided:

add

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);

rw

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));

Retrieving data

Fllat tries to use some simple and standard data retrieval methods, some of which are adapted from SQL. Here are the basics:

get

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"

select

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"]]

Flexibility

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!

Contributing

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.

Meta

Build status

Build Status

Version

Fllat is currently at version 0.1.0.

License

Fllat is licensed for use under the terms stated in the LICENSE.md file.

fllat's People

Contributors

alfredxing avatar jongacnik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.