| @@ 276-294 (lines=19) @@ | ||
| 273 | * @param resource $connection = null The connection to use (null to use $db_connection) |
|
| 274 | * @return string The string with the values inserted |
|
| 275 | */ |
|
| 276 | function smf_db_quote($db_string, $db_values, $connection = null) |
|
| 277 | { |
|
| 278 | global $db_callback, $db_connection; |
|
| 279 | ||
| 280 | // Only bother if there's something to replace. |
|
| 281 | if (strpos($db_string, '{') !== false) |
|
| 282 | { |
|
| 283 | // This is needed by the callback function. |
|
| 284 | $db_callback = array($db_values, $connection === null ? $db_connection : $connection); |
|
| 285 | ||
| 286 | // Do the quoting and escaping |
|
| 287 | $db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', 'smf_db_replacement__callback', $db_string); |
|
| 288 | ||
| 289 | // Clear this global variable. |
|
| 290 | $db_callback = array(); |
|
| 291 | } |
|
| 292 | ||
| 293 | return $db_string; |
|
| 294 | } |
|
| 295 | ||
| 296 | /** |
|
| 297 | * Do a query. Takes care of errors too. |
|
| @@ 320-338 (lines=19) @@ | ||
| 317 | * @param resource $connection = null The connection to use (null to use $db_connection) |
|
| 318 | * @return string The string with the values inserted |
|
| 319 | */ |
|
| 320 | function smf_db_quote($db_string, $db_values, $connection = null) |
|
| 321 | { |
|
| 322 | global $db_callback, $db_connection; |
|
| 323 | ||
| 324 | // Only bother if there's something to replace. |
|
| 325 | if (strpos($db_string, '{') !== false) |
|
| 326 | { |
|
| 327 | // This is needed by the callback function. |
|
| 328 | $db_callback = array($db_values, $connection === null ? $db_connection : $connection); |
|
| 329 | ||
| 330 | // Do the quoting and escaping |
|
| 331 | $db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', 'smf_db_replacement__callback', $db_string); |
|
| 332 | ||
| 333 | // Clear this global variable. |
|
| 334 | $db_callback = array(); |
|
| 335 | } |
|
| 336 | ||
| 337 | return $db_string; |
|
| 338 | } |
|
| 339 | ||
| 340 | /** |
|
| 341 | * Do a query. Takes care of errors too. |
|