Skip to content
Devin Smith edited this page Feb 3, 2016 · 11 revisions

Tipsy provides a simple ORM for SQL.


Methods

load

Load is called on class instantiation, or when called using object notation. Accepts either an id, an array, or ab object to construct.

Load the object by $id from the database

$User->load($id);

or

User::o($id);

Create a new object with an array. You may also pass an object instead of an array in replace of any of the 3 examples below.

$user = $User->load([
	name => 'devin'
]);

or

$user = new User([
	name => 'devin'
]);

or

$user = User::o([
	name => 'devin'
]);

Examples

Loading an item using route params

// create the User model based on the resource class
$tipsy->service('User', [
	_id => 'id',
	_table => 'user'
]);
// load the user when the route is visited and display the user name
$tipsy->when('user/:id', function($Params, $User) {
	echo $User->load($Params->id)->name;
});