There is no license information available for the latest version (dev-master) of this package.

dev-master 2014-05-22 13:19 UTC

This package is not auto-updated.

Last update: 2019-10-14 07:43:30 UTC


README

Simple mysqli wrapper so you don't have to write all your SQL all by yourself.

Learn by example

$db = new DB(new MySQLi(...), $optionalTableNamePrefix);

// access users table
$usersTable = $db->users;

// get user with id 1
$user = $db->users->id(1);
// $user is just still a table instance

// get users with ids 1, 2 and 5
$users = $db->users->id(1, 2, 5);

// get users who are over 10 years of age and like ponies
$users = $db->users
  ->age->gt(10) // or ->filter('age > 10')
  ->favoriteAnimal('ponies');

// all $users are still table instances, so you can apply more filters
// eg. we also want only male users:
$users = $users->gender('male');

// now if we want to use the user data...
$userIds = $users->get('id');
$userObjects = $users->fetch();
$userObjects[0]->gender; // 'male'

// If we only expect one result, use getOne & fetchOne
$userId = $db->users->name('obama')->getOne('id');
$jobs = $db->users->name('steveJobs123')->fetch();
$jobs->favoriteAnimal; // ???

// Set Steve's favorite animal
$jobs->set('favoriteAnimal', 'camel')->update();


// What? We have a new registrant!
$newUserId = $db->users->insert(array(
  'name' => 'MisterX',
  'age' => 25,
  'favoriteAnimal' => 'mole'
));

// ... there's more probably