26 liens privés
/**
- Debugging version of db_query().
- Echoes the query to the browser. (Print a SQL string from db_query())
- @param $query
- The prepared statement query to run. Although it will accept both named and
- unnamed placeholders, named placeholders are strongly preferred as they are
- more self-documenting.
- @param $args
- An array of values to substitute into the query. If the query uses named
- placeholders, this is an associative array in any order. If the query uses
- unnamed placeholders (?), this is an indexed array and the order must match
- the order of placeholders in the query string.
- @param $options
- An array of options to control how the query operates.
- @param $return
- Whether to return the string in $result param or print the string. Default to FALSE.
- @param $name
- Optional name for identifying the output.
- @return DatabaseStatementInterface
- A prepared statement object, already executed.
-
@see db_query()
*/
function db_queryd($query, array $args = array(), array $options = array(), &$return = FALSE, $name = NULL) {
if (!user_access('access devel information')) {
return db_query($query, $args, $options);
}$db_query_res = db_query($query, $args, $options);
$sql = (string) $db_query_res->getQueryString();
$quoted = array();
$connection = Database::getConnection();
foreach ($args as $key => $val) {
if (is_int($key)) {
$sql = preg_replace('/\?/', $connection->quote($val), $sql);
}
else {
$quoted[$key] = $connection->quote($val);
}
}
$sql = strtr($sql, $quoted);
if ($return) {
$return = $sql;
}
else {
dpm($sql, (string) $name);
}
return $db_query_res;
}
Il faut installer pipe viewer
On Ubuntu/Debian system
$ sudo apt-get install pv
On Redhat/CentOS
$ sudo yum install pv
Puis
$ pv sqlfile.sql | mysql -uxxx -pxxxx dbname
pipe viewer affiche la progression du dump.