summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/db.php b/lib/db.php
index 5a91421f7ab..8f6f50bda6e 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -367,7 +367,9 @@ class OC_DB {
// Optimize the query
$query = self::processQuery( $query );
-
+ if(OC_Config::getValue( "log_query", false)) {
+ OC_Log::write('core', 'DB prepare : '.$query, OC_Log::DEBUG);
+ }
self::connect();
// return the result
if(self::$backend==self::BACKEND_MDB2) {
@@ -952,6 +954,10 @@ class PDOStatementWrapper{
* make execute return the result instead of a bool
*/
public function execute($input=array()) {
+ if(OC_Config::getValue( "log_query", false)) {
+ $params_str = str_replace("\n"," ",var_export($input,true));
+ OC_Log::write('core', 'DB execute with arguments : '.$params_str, OC_Log::DEBUG);
+ }
$this->lastArguments = $input;
if (count($input) > 0) {
@@ -1071,7 +1077,7 @@ class PDOStatementWrapper{
public function numRows() {
$regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i';
if (preg_match($regex, $this->statement->queryString, $output) > 0) {
- $query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}", PDO::FETCH_NUM);
+ $query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}");
return $query->execute($this->lastArguments)->fetchColumn();
}else{
return $this->statement->rowCount();