Skip to content
/ easy-sql Public

Builds on Aura's ExtendedPdo to add database manipulation helpers and persistent connections

Notifications You must be signed in to change notification settings

M1ke/easy-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy SQL

An extension to Aura.Sql which simplifies object creation, adds extra database manipulation methods, extra fetch methods and a PersistendPdo class for long-lived connections as part of event driven applications.

Use

use M1ke\Sql\ExtendedPdo;

$pdo = new ExtendedPdo('database', 'user', 'pass');

$user_id = $pdo->insert('users', ['name'=>'Foo', 'email'=>'foo@bar.com']);
// user created, returns ID

$affected_rows = $pdo->update('users', "SET :params WHERE user_id={$user_id}", ['name'=>'Bar']);
// user name changed to "Bar", returns number of rows affected

For real time applications simply run methods on the static PersistPdo object:

use M1ke\Sql\PersistPdo;

PersistPdo::setConfig('database', 'user', 'pass');
PersistPdo::fetchOne("SELECT * FROM users WHERE user_id = 1");
// returns ['user_id'=>1, name'=>'Bar', 'email'=>'foo@bar.com']

About

Builds on Aura's ExtendedPdo to add database manipulation helpers and persistent connections

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages