-
Notifications
You must be signed in to change notification settings - Fork 4
/
tester.php
executable file
·52 lines (43 loc) · 1.27 KB
/
tester.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
50
51
52
<?php
/**
* User: ethanhayon
* Date: 10/27/12
* Time: 12:11 AM
*/
include("lib/phporm/mysql.php");
include("lib/phporm/model.php");
$db = new Database();
$db->setup("localhost", "root", "", "ParkingManagementSystem");
Model::setDB($db);
class ParkingLot extends Model {
protected static $table_name = "parkinglots"; // we can override the table name for
}
class Comment extends Model {
protected static $table_name = "comments"; // we can override the table name for
}
//$lot = ParkingLot::findOne("status='1'", "", "");
ParkingLot::has_one(new Comment);
/* // Create a new lot
$lot = new ParkingLot();
$lot->location = "test lot";
$lot->status = 1;
$lot->available = 200;
$lot->capacity = 1000;
$lot->save();
*/
/* // create a new comment for testing
$comment = new Comment();
$comment->comment = "This lot also sucks";
$comment->save();
*/
$comment1 = Comment::findOne(array("id_comment"=>2), null);
//$comment2 = Comment::findOne(array("id_comment"=>20), null);
$lot = ParkingLot::findOne(array("id_parkinglot"=>1), null);
if(isset($lot)) {
$lot->location = "test lot location";
$lot->comment = $comment1;
$lot->save();
print '<br />$lot->comment = '.$lot->id_comment.'<br />';
print "<br /><br />GET Comment for lot: ";
var_dump($lot->comment);
}