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