Code Monkey home page Code Monkey logo

sqlite-dbintrd's Introduction

DBIntrd - Simple PHP framework for SQLite3 databases. A magic way to automatically create objects and persists data at SQLite3 tables.
Package intrd/sqlite-dbintrd
Version 2.0
Tags php, sqlite, framework, database
Project URL http://github.com/intrd/sqlite-dbintrd
Author intrd (Danilo Salles) - http://dann.com.br
Copyright (CC-BY-SA-4.0) 2016, intrd
License Creative Commons Attribution-ShareAlike 4.0
Dependencies โ€ข php >=5.3.0

System & Composer installation

$ sudo apt-get update & apt-get upgrade
$ sudo apt-get install curl php-curl php-cli php-sqlite
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Usage sample

Assuming your project are running over Composer PSR-4 defaults, simply Require it on your composer.json

"require": {
    "intrd/sqlite-dbintrd": ">=2.0.x-dev <dev-master"
}

And run..

$ composer install -o #to install
$ composer update -o #to update

Always use -o to rebuild autoload.

Now Composer Autoload will instance the class and you are able to use by this way..

require __DIR__ . '/vendor/autoload.php';
use database\dbintrd as db;

$root=dirname(__FILE__)."/"; 
$db_path=$root.'vendor/intrd/sqlite-dbintrd/data/sample.dat'; //path of SQLite sample.dat (sample database included)
$debug=true; //enable SQL queries debug

/*
 * GET all data from table=users
 */
$users = new db("users","all"); 
var_dump($users); //print data

/*
 * GET all data from table=orders + CHILDS data
 */
$users = new db("orders","all",true); 
var_dump($users); //print data

/*
 * GET from tables=users, object where id=40, SET a different email and UPDATE
 */
$user = new db("users",40); 
$user->{0}->email="[email protected]"; 
var_dump($user); 
$user->save(true); 

/*
 * CREATE a fresh new object where table=users, SET a email and password and INSERT 
 */
$user = new db("users"); 
$user->email="[email protected]"; 
$user->password="123"; 
var_dump($user);
$user->save(); 

/*
 * GET a object from table=users filtering where [email protected]
 */
$users = new db("users","filter:email|[email protected]"); 
var_dump($users); 

/*
 * GET a object from table=users w/ combined filtering (following SQLite sintax)
 */
$users = new db("users","filter:email='[email protected]' and email='[email protected]'"); 
var_dump($users); //print data

/*
 * GET a object from table=orders filtering and returning CHILDS
 */
$orders = new db("orders","filter:qty|11",TRUE); 
var_dump($orders); 

/**
 * FULL CUSTOM SELECT (following SQLite sintax)
 */
$users = new db("users","custom:SELECT users.email FROM users WHERE id=40",false);

Todo list

  • SELECTS are propagating to Childs at application side, do the same at SQLite side w/ a single JOIN query to return child array objects (look src/classes.php nearby line 123)

sqlite-dbintrd's People

Contributors

intrd avatar

Watchers

James Cloos avatar  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.