m1ke / easy-sql
Builds on Aura's ExtendedPdo to add database manipulation helpers and persistent connections
Installs: 59 941
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=5.3.0
- aura/sql: ^2.4.3
Requires (Dev)
- m1ke/git-php-lint: 1.0.0
- phpunit/phpunit: 4.5.0
README
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']