|
4 | 4 | require_once ("../dbObject.php"); |
5 | 5 |
|
6 | 6 | $db = new Mysqlidb('localhost', 'root', '', 'testdb'); |
| 7 | +$prefix = 't_'; |
| 8 | +$db->setPrefix($prefix); |
7 | 9 | dbObject::autoload ("models"); |
8 | 10 |
|
9 | 11 | $tables = Array ( |
@@ -91,8 +93,8 @@ function createTable ($name, $data) { |
91 | 93 |
|
92 | 94 | // rawQuery test |
93 | 95 | foreach ($tables as $name => $fields) { |
94 | | - $db->rawQuery("DROP TABLE " . $name); |
95 | | - createTable ($name, $fields); |
| 96 | + $db->rawQuery("DROP TABLE " . $prefix . $name); |
| 97 | + createTable ($prefix . $name, $fields); |
96 | 98 | } |
97 | 99 |
|
98 | 100 | foreach ($data as $name => $datas) { |
@@ -134,7 +136,7 @@ function createTable ($name, $data) { |
134 | 136 | exit; |
135 | 137 | } |
136 | 138 |
|
137 | | -$depts = product::join('user')->orderBy('products.id', 'desc')->get(5); |
| 139 | +$depts = product::join('user')->orderBy('t_products.id', 'desc')->get(5); |
138 | 140 | foreach ($depts as $d) { |
139 | 141 | if (!is_object($d)) { |
140 | 142 | echo "Return should be an object\n"; |
@@ -244,21 +246,21 @@ function createTable ($name, $data) { |
244 | 246 | if (!is_array (user::ArrayBuilder()->byId(1))) |
245 | 247 | echo "wrong return type2"; |
246 | 248 |
|
247 | | -if (!is_array (product::join('user')->orderBy('products.id', 'desc')->get(2))) |
| 249 | +if (!is_array (product::join('user')->orderBy('t_products.id', 'desc')->get(2))) |
248 | 250 | echo "wrong return type2"; |
249 | 251 |
|
250 | | -if (!is_array (product::orderBy('products.id', 'desc')->join('user')->get(2))) |
| 252 | +if (!is_array (product::orderBy('t_products.id', 'desc')->join('user')->get(2))) |
251 | 253 | echo "wrong return type2"; |
252 | 254 |
|
253 | 255 | $u = new user; |
254 | 256 | if (!$u->byId(1) instanceof user) |
255 | 257 | echo "wrong return type2"; |
256 | 258 |
|
257 | 259 | $p = new product; |
258 | | -if (!is_array ($p->join('user')->orderBy('products.id', 'desc')->get(2))) |
| 260 | +if (!is_array ($p->join('user')->orderBy('t_products.id', 'desc')->get(2))) |
259 | 261 | echo "wrong return type2"; |
260 | 262 |
|
261 | | -if (!is_array ($p->orderBy('products.id', 'desc')->join('user')->get(2))) |
| 263 | +if (!is_array ($p->orderBy('t_products.id', 'desc')->join('user')->get(2))) |
262 | 264 | echo "wrong return type2"; |
263 | 265 |
|
264 | 266 | echo "All done"; |
|
0 commit comments