Menu

[r1]: / sampleCode / addLots.php  Maximize  Restore  History

Download this file

179 lines (127 with data), 4.7 kB

  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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/*
********************************************************
Name: addLots.php
Author: Rob Hunter
Date 1/14/11
Description: I used this file to add a bunch of objects quickly
to test the queries. Nothing new here in relation to addCar.php
********************************************************
*/
require_once('../lib/initHunterDB.php');
//add 3 cars
echo 'add cars<br><br>';
$myCar = new HDB_Content( 'Ford Explorer',
'Car',
""
);
$myCar->my->make = "Ford";
$myCar->my->model = "Rob's Explorer";
$myCar->my->year = 1998;
$myCar->my->color = "Tan";
print $myCar->debugHTML();
$myCar->save();
$myCar = new HDB_Content( 'Toyota Sienna',
'Car',
""
);
$myCar->my->make = "Toyota";
$myCar->my->model = "Sienna";
$myCar->my->year = 2002;
$myCar->my->color = "White";
print $myCar->debugHTML();
$myCar->save();
$myCar = new HDB_Content( 'Ford Mustang',
'Car',
""
);
$myCar->my->make = "Ford";
$myCar->my->model = "Mustang";
$myCar->my->year = 2004;
$myCar->my->color = "Crimson";
print $myCar->debugHTML();
$myCar->save();
//add 3 users
echo 'add users<br><br>';
$myUser = new HDB_Content( 'Rob Hunter',
'User',
""
);
$myUser->my->firstName = "Rob";
$myUser->my->lastName = "Hunter";
$myUser->my->birthDate = '05-15-1986';
$myUser->my->hometown = "Buffalo, NY";
$myUser->my->email = "rob.v.hunter@gmail.com";
print $myUser->debugHTML();
$myUser->save();
$myUser = new HDB_Content( 'Theresa Geiger',
'User',
""
);
$myUser->my->firstName = "Theresa";
$myUser->my->lastName = "Geiger";
$myUser->my->birthDate = '08-04-1989';
$myUser->my->hometown = "Chicago, IL";
$myUser->my->email = "dontemailmygirlfriend@gmail.com";
print $myUser->debugHTML();
$myUser->save();
$myUser = new HDB_Content( 'Rebecca Hunter',
'User',
""
);
$myUser->my->firstName = "Rebecca";
$myUser->my->lastName = "Hunter";
$myUser->my->birthDate = '06-13-1994';
$myUser->my->hometown = "Buffalo, NY";
$myUser->my->email = "dontemailmysister@gmail.com";
print $myUser->debugHTML();
$myUser->save();
//add 3 airports
echo 'add airports<br><br>';
$myAirport = new HDB_Content( 'Los Angeles International Airport',
'Airport',
""
);
$myAirport->my->address = "1 World Way, Los Angeles, CA 90045";
$myAirport->my->abbreviation = "LAX";
$myAirport->my->yearFounded = 1949;
$myAirport->my->city = "Los Angeles";
$myAirport->my->zip = 90045;
print $myAirport->debugHTML();
$myAirport->save();
$myAirport = new HDB_Content( 'Fort Lauderdale-Hollywood International Airport',
'Airport',
""
);
$myAirport->my->address = "Terminal Dr, Fort Lauderdale, FL";
$myAirport->my->abbreviation = "FLL";
$myAirport->my->yearFounded = 1946;
$myAirport->my->city = "Fort Lauderdale";
$myAirport->my->zip = 33315;
print $myAirport->debugHTML();
$myAirport->save();
$myAirport = new HDB_Content( "O'hare International Airport",
'Airport',
""
);
$myAirport->my->address = "5600 Mannheim Rd, Chicago, IL 60666-1007";
$myAirport->my->abbreviation = "ORD";
$myAirport->my->yearFounded = 1955;
$myAirport->my->city = "Chicago";
$myAirport->my->zip = 60666;
print $myAirport->debugHTML();
$myAirport->save();
echo "Query Run <br><br><br>";
$query = new HDB_Query();
$query->filter('type','=','Car');
$results = $query->execute();
if (!empty($results)){
foreach ($results as $result){
//print_r($result);
print $result->debugHTML();
}
}
else{
echo 'No results<br><br>';
}
?>
MongoDB Logo MongoDB