-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
49 lines (39 loc) · 945 Bytes
/
app.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
require "rb.php";
R::setup("mysql:host=localhost;dbname=rb", "root", "01");
// R::freeze(1);
// Insert
$user = R::dispense("user");
$user->username = "max";
$user->password = sha1("hey");
$user->status = 1;
$user->balance = 1200;
$id = R::store($user);
print "User ID: $id\n";
// Update
$user = R::load("user", 1);
$user->balance += 100;
R::store($user);
// Delete
$user = R::load("user", 1);
R::trash($user);
// Select All
$users = R::findAll("user");
$user = R::load("user", $users[0]->id);
$user->balance += 4;
R::store($user);
print_r($user);
// Get Rows
$users = R::getAll("SELECT * FROM user");
print_r($users);
// Get a Row
$user = R::getRow("SELECT * FROM user");
print_r($user);
// Get a Row
$user = R::getRow("SELECT * FROM user WHERE id = ?",[1]);
print_r($user);
// Get a Row
$user = R::getRow("SELECT * FROM user WHERE id = :id",["id" => 1]);
print_r($user);
// Delete
R::exec("DELETE FROM user WHERE id = ?", [2]);