forked from iRail/The-DataTank-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rb.php
42 lines (33 loc) · 1.19 KB
/
test_rb.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
<?php
include_once('Config.class.php');
include_once('rb.php');
// This is how you configure it.
R::setup(Config::$DB, Config::$DB_USER, Config::$DB_PASSWORD);
// This is how you create a bean.
$message1 = R::dispense('feedback_messages');
$message1->url_request = 'http://localhost/Test123';
$message1->msg = 'test123';
$id1 = R::store($message1);
$message2 = R::dispense('feedback_messages');
$message2->url_request = 'http://localhost/Test456';
$message2->msg = 'test456';
$id2 = R::store($message2);
echo 'Message 1 id: ' . $id1 . "\n";
echo 'Message 2 id: ' . $id2 . "\n";
// This is how you get an existing bean.
$message3 = R::load('feedback_messages', $id1);
echo 'Message 1 & 3: ' . ($message1->getID() == $message3->getID()) . "\n";
// This is how you update a bean.
$message2->url_request = 'http://localhost/Test678';
$id2 = R::store($message2);
// This is how you find a bean, no sql-injection possible.
$message4 = R::findOne(
'feedback_messages',
'url_request = :url_request',
array(':url_request' => 'http://localhost/Test678')
);
echo 'Message 2 & 4: ' . ($message2->getID() == $message4->getID()) . "\n";
// This is how you delete a bean.
R::trash($message1);
R::trash($message2);
?>