|
@@ -200,22 +200,22 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
|
|
201
|
201
|
case 'date': |
|
202
|
202
|
if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
203
|
|
- return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
|
203
|
+ return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]) . '::date'; |
|
204
|
204
|
else |
|
205
|
205
|
smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
206
|
206
|
break; |
|
207
|
207
|
|
|
208
|
208
|
case 'time': |
|
209
|
209
|
if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
210
|
|
- return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
|
210
|
+ return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]) . '::time'; |
|
211
|
211
|
else |
|
212
|
212
|
smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
213
|
213
|
break; |
|
214
|
214
|
|
|
215
|
215
|
case 'datetime': |
|
216
|
216
|
if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
217
|
|
- return 'to_timestamp('. |
|
218
|
|
- sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
|
217
|
+ return 'to_timestamp(' . |
|
|
218
|
+ sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
219
|
219
|
',\'YYYY-MM-DD HH24:MI:SS\')'; |
|
220
|
220
|
else |
|
221
|
221
|
smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
@@ -475,7 +475,7 @@ discard block |
|
|
block discarded – undo |
|
475
|
475
|
$query_hints_set .= 'SET LOCAL join_collapse_limit = 1;'; |
|
476
|
476
|
} |
|
477
|
477
|
|
|
478
|
|
- $db_string = $query_hints_set .' |
|
|
478
|
+ $db_string = $query_hints_set . ' |
|
479
|
479
|
' . $db_string; |
|
480
|
480
|
} |
|
481
|
481
|
|
|
@@ -785,10 +785,10 @@ discard block |
|
|
block discarded – undo |
|
785
|
785
|
$returning = ''; |
|
786
|
786
|
$with_returning = false; |
|
787
|
787
|
// lets build the returning string, mysql allow only in normal mode |
|
788
|
|
- if(!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0) |
|
|
788
|
+ if (!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0) |
|
789
|
789
|
{ |
|
790
|
790
|
// we only take the first key |
|
791
|
|
- $returning = ' RETURNING '.$keys[0]; |
|
|
791
|
+ $returning = ' RETURNING ' . $keys[0]; |
|
792
|
792
|
$with_returning = true; |
|
793
|
793
|
} |
|
794
|
794
|
|
|
@@ -819,7 +819,7 @@ discard block |
|
|
block discarded – undo |
|
819
|
819
|
INSERT INTO ' . $table . '("' . implode('", "', $indexed_columns) . '") |
|
820
|
820
|
VALUES |
|
821
|
821
|
' . implode(', |
|
822
|
|
- ', $insertRows).$replace.$returning, |
|
|
822
|
+ ', $insertRows) . $replace . $returning, |
|
823
|
823
|
array( |
|
824
|
824
|
'security_override' => true, |
|
825
|
825
|
'db_error_skip' => $method == 'ignore' || $table === $db_prefix . 'log_errors', |
|
@@ -832,7 +832,7 @@ discard block |
|
|
block discarded – undo |
|
832
|
832
|
if ($returnmode === 2) |
|
833
|
833
|
$return_var = array(); |
|
834
|
834
|
|
|
835
|
|
- while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
|
835
|
+ while (($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
836
|
836
|
{ |
|
837
|
837
|
if (is_numeric($row[0])) // try to emulate mysql limitation |
|
838
|
838
|
{ |