Skip to content

Linnk/Autobahn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Autobahn

A simple ORM (Object-Relational Mapping) library for PHP5

Autobahn is a bit far from the simple ORM would like, however, is already a very good database abstraction. I will be focused on developing and refining this layer of the system, which provides:

- Manager of connections to the database
- Magic Methods for access to data
- SQL Query Builder
- Extend the support database

KISS – «Keep It Short and Simple»

/* Loading Autobahn
-------------------------- */
require 'lib/autobahn.php';

$library = Autobahn::getConnection(array(
	'driver' 	=> 'mysql',
	'host' 		=> 'localhost',
	'user' 		=> 'root',
	'password' 	=> 'root',
	'database' 	=> 'spumer_db',
));


/* Classic SQL
---------------------------------------------------------- */
$users = $library->query('SELECT User.* FROM users User;');


/* Magic Find All
--------------------------------- */
$users = $library->findAllUsers();


/* Magic Find Some
------------------------------------------------ */
$users = $library->findAllUsersById(array(1, 2));


/* Magic Find One
---------------------------------------------------------- */
$user = $library->findUsersByUsername('fake@username.com');


/* Magic Insert
---------------------------------------------------------------------- */
$new_user = array('username' => 'fake@username.com', 'name' => 'Fake');

$library->insertUsers($new_user);


/* Magic Update
--------------------------------------------- */
$values     = array('name' => 'Totally fake');
$conditions = array('username' => 'fake@username.com');

$library->updateUsers($values, $conditions);


/* Magic Delete
---------------------------- */
$library->deleteUsersById(4);

The magic of Autobahn::getConnection() is Singleton, and it return an object construct with the database objects (dbo) of your database selected, I mean, when I can get ti write others dbo’s. PostgreSQL will be next in my list.

About

Autobahn is a simple ORM library for PHP5

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages