function DB_mysql::modifyQuery in Flickr API 5
Changes a query string for various DBMS specific reasons
This little hack lets you know how many rows were deleted when running a "DELETE FROM table" query. Only implemented if the DB_PORTABILITY_DELETE_COUNT portability option is on.
@access protected
Parameters
string $query the query string to modify:
Return value
string the modified query string
Overrides DB_common::modifyQuery
See also
1 call to DB_mysql::modifyQuery()
- DB_mysql::simpleQuery in phpFlickr/
PEAR/ DB/ mysql.php - Sends a query to the database server
File
- phpFlickr/
PEAR/ DB/ mysql.php, line 820
Class
- DB_mysql
- The methods PEAR DB uses to interact with PHP's mysql extension for interacting with MySQL databases
Code
function modifyQuery($query) {
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
// "DELETE FROM table" gives 0 affected rows in MySQL.
// This little hack lets you know how many rows were deleted.
if (preg_match('/^\\s*DELETE\\s+FROM\\s+(\\S+)\\s*$/i', $query)) {
$query = preg_replace('/^\\s*DELETE\\s+FROM\\s+(\\S+)\\s*$/', 'DELETE FROM \\1 WHERE 1=1', $query);
}
}
return $query;
}