@@ -141,6 +141,7 @@ public function escape($string) {
141
141
}
142
142
143
143
public function reload () {
144
+ $ this ->connect = NULL ;
144
145
$ this ->__construct ();
145
146
}
146
147
@@ -150,6 +151,8 @@ public function query($query, $flags = 0, $fnc = "Query") {
150
151
$ qr = $ this ->connect ->query ($ query );
151
152
if (!$ qr && !($ flags & self ::NO_ERROR ))
152
153
throw new SSQLException ("( " . $ fnc . "): Database error: <em> " . $ this ->connect ->errorInfo ()[2 ] . "</em> <strong>SQL command:</strong> <code> " . (empty ($ query ) ? "<em>Missing</em> " : $ query ) . "</code> " );
154
+ elseif (!$ qr )
155
+ return false ;
153
156
$ this ->result = new SSQLResult ($ qr );
154
157
return $ this ->result ;
155
158
}
@@ -403,7 +406,14 @@ public function insert($table, $values, $flags = 0) {
403
406
$ valueString = "" ;
404
407
foreach ($ values as $ key => $ value ) {
405
408
if ($ key !=array_keys ($ values , array_values ($ values )[0 ])[0 ]) $ valueString .= ", " ;
406
- $ valueString .= $ value ===NULL ? "NULL " : ("' " . $ this ->escape ($ value ) . "' " );
409
+ if ($ value ===NULL )
410
+ $ valueString .= "NULL " ;
411
+ elseif (preg_match ("/^[\x{0020}-\x{007E}\x{00A0}-ſ]*$/ " , $ value ))
412
+ $ valueString .= "' " . $ this ->escape ($ value ) . "' " ;
413
+ elseif ($ this ->SQLite )
414
+ $ valueString .= "x' " . bin2hex ($ value ) . "' " ;
415
+ else
416
+ $ valueString .= "0x " . bin2hex ($ value );
407
417
};
408
418
$ r = $ this ->query ("
409
419
INSERT INTO $ table$ colString VALUES ( $ valueString)
@@ -426,7 +436,15 @@ public function update($table, $cond, $values, $flags = 128) {
426
436
foreach ($ values as $ key => $ value ) {
427
437
if ($ string !="" )
428
438
$ string .= ", " ;
429
- $ string .= "` " . $ this ->escape ($ key ) . "`= " . ($ value ===NULL ? "NULL " : ("' " . $ this ->escape ($ value ) . "' " ));
439
+ $ string .= "` " . $ this ->escape ($ key ) . "`= " ;
440
+ if ($ value ===NULL )
441
+ $ string .= "NULL " ;
442
+ elseif (preg_match ("/^[\x{0020}-\x{007E}\x{00A0}-ſ]*$/ " , $ value ))
443
+ $ string .= "' " . $ this ->escape ($ value ) . "' " ;
444
+ elseif ($ this ->SQLite )
445
+ $ string .= "x' " . bin2hex ($ value ) . "' " ;
446
+ else
447
+ $ string .= "0x " . bin2hex ($ value );
430
448
};
431
449
return $ this ->query ("
432
450
UPDATE ` $ table` SET $ string WHERE $ condString
@@ -671,7 +689,7 @@ private function getCondString($a, $and, $on = false) {
671
689
return rtrim ($ r , $ and ? " AND " : " OR " );
672
690
}
673
691
public function __debugInfo () {
674
- return ['host ' => $ this ->host , 'user ' => $ this ->user , 'password ' => preg_replace ("/./ " , "* " , $ this ->password ), 'database ' => $ this ->db , 'lastError ' => $ this ->connect ->errorInfo ()];
692
+ return ['db ' => ( $ this -> SQLite ? " SQLite " : " MySQL " ), ( $ this -> SQLite ? ' file ' : ' host ') => $ this ->host , 'user ' => $ this ->user , 'password ' => preg_replace ("/./ " , "* " , $ this ->password ), 'database ' => $ this ->db , 'lastError ' => $ this ->connect ->errorInfo ()];
675
693
}
676
694
public function __sleep () {
677
695
if ($ this ->result instanceof PDOStatement)
0 commit comments