Welcome Guest, Not a member yet? Register   Sign In
Elegant ORM
#2

[eluser]Unknown[/eluser]
Some examples:

Defining models

Code:
class User extends Elegant\Model {
  // the name of table to work with
  protected $table = "user";
}
// That's it!

Querying

Code:
// Get all users
$users = User::all();
foreach($users as $user)
{
  echo $user->name;
}

// Find particular user(s) by its primary key
$user = User::find(1);
echo $user->name;

Creating New Model
Code:
$user =  new User;

$user->name = 'John Doe';
$user->email = '[email protected]';

$user->save();

Updating Models
Code:
$user = User::find(1);

$user->name = 'Jack Doe';
$user->save();


Messages In This Thread
Elegant ORM - by El Forum - 09-02-2013, 09:08 PM
Elegant ORM - by El Forum - 09-02-2013, 09:13 PM
Elegant ORM - by El Forum - 08-12-2014, 07:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB