function db_query_range($query) { $args = func_get_args(); $count = array_pop($args); $from = array_pop($args); array_shift($args); if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax $args = $args[0]; } db_query_callback($args, TRUE); $query = preg_replace_callback(DB_QUERY_REGEXP, 'db_query_callback', $query); $query .= ' LIMIT ' . (int) $from . ', ' . (int) $count; return $query; }
function db_query($query) { @prf_start("db_query"); @prf_start(substr($query, 0, 20)); global $db_query_error_function; $args = func_get_args(); array_shift($args); if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax $args = $args[0]; } db_query_callback($args, TRUE); if (mysql) { $query = db_sqlite2mysql_sql($query); } if ($query == "") { return; } $query = preg_replace_callback('/(%d|%s|%%|%f|%b)/', 'db_query_callback', $query); if (mysql) { $res = mysql_query($query); if (!$res) { $db_query_error_function("<h1>MYSQL ERROR</h1><br> {$query}<br>" . mysql_error()); } } global $dbhandle; if (sqlite2) { $res = sqlite_query($dbhandle, $query); if ($res == FALSE) { $db_query_error_function("<h1>SQL ERROR</h1><br> {$query}<br>" . sqlite_error_string($dbhandle)); } } if (sqlite3) { $res = $dbhandle->query($query); if ($res == FALSE) { $db_query_error_function("<h1>SQL ERROR</h1><br> {$query}<br>" . sqlite_error_string($dbhandle)); } } if (pdo_sqlite) { $res = $dbhandle->query($query); } global $sqllog; $sqllog .= $query . "<br>"; @prf_end(); @prf_end(); return $res; }