@@ -16,6 +16,7 @@ public function __construct(\mysqli $mysqli)
16
16
17
17
protected function query (string $ query ) : array
18
18
{
19
+ echo PHP_EOL . $ query . PHP_EOL ;
19
20
$ results = $ this ->mysqli ->query ($ query );
20
21
if ($ this ->mysqli ->errno ) {
21
22
throw new \Exception ($ this ->mysqli ->error . $ query );
@@ -31,26 +32,26 @@ protected function query(string $query) : array
31
32
32
33
public function orderBy (array $ args )
33
34
{
34
- $ order = 'ORDER BY ' ;
35
+ $ order = ' ORDER BY ' ;
35
36
foreach ($ args as $ key => $ value ) {
36
37
$ key = $ this ->mysqli ->escape_string ($ key );
37
38
$ value = $ this ->mysqli ->escape_string ($ value );
38
- $ order .= ' ` ' . $ key . '` ' . strtoupper ($ value ) . ' ' ;
39
+ $ order .= $ this -> model . ' . ` ' . $ key . '` ' . strtoupper ($ value ) . ', ' ;
39
40
}
40
- $ this ->order = trim ( $ order );
41
+ $ this ->order = rtrim ( substr ( $ order, 0 , - 2 ) );
41
42
return $ this ;
42
43
}
43
44
44
45
45
46
public function where (array $ args , string $ method = 'AND ' )
46
47
{
47
- $ search = 'WHERE ' ;
48
+ $ search = ' WHERE ' ;
48
49
foreach ($ args as $ key => $ value ) {
49
50
$ key = $ this ->mysqli ->escape_string ($ key );
50
51
$ value = $ this ->mysqli ->escape_string ($ value );
51
- $ search .= ' ` ' . $ key . '` = " ' . $ value . '" ' . $ method ;
52
+ $ search .= $ this -> model . ' . ` ' . $ key . '` = " ' . $ value . '" ' . $ method ;
52
53
}
53
- $ this ->conditions .= trim (substr ($ search , 0 , -strlen ($ method )));
54
+ $ this ->conditions .= rtrim (substr ($ search , 0 , -strlen ($ method )));
54
55
return $ this ;
55
56
}
56
57
}
0 commit comments