-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
32 lines (26 loc) · 727 Bytes
/
Copy pathexample.php
File metadata and controls
32 lines (26 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
// Example Usage
require 'vendor/autoload.php';
use Sommy\ORM\SommyManager;
use Sommy\ORM\DataTypes;
$orm = new SommyManager([
'dialect' => 'mysql',
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => 'testdb',
'storage' => __DIR__ . '/db.sqlite',
]);
$User = $orm->define('User', [
'id' => DataTypes::INTEGER(),
'name' => DataTypes::STRING(100),
'email' => DataTypes::STRING(150),
], [
'tableName' => 'users'
]);
$orm->getQueryInterface()->createTable('users', $User::$attributes);
$user = new $User;
$user->name = 'Clinton';
$user->email = 'clinton@example.com';
$user->save();
$all = $User::findAll(['email' => 'clinton@example.com']);