Browse Source

Add Connection::disableQueryLogging().

ADmad 7 years ago
parent
commit
5fe3e0c16a

+ 12 - 0
src/Database/Connection.php

@@ -876,6 +876,18 @@ class Connection implements ConnectionInterface
     }
 
     /**
+     * Disable query logging
+     *
+     * @return $this
+     */
+    public function disableQueryLogging()
+    {
+        $this->_logQueries = false;
+
+        return $this;
+    }
+
+    /**
      * Check if query logging is enabled.
      *
      * @return bool

+ 1 - 0
src/Datasource/ConnectionInterface.php

@@ -26,6 +26,7 @@ namespace Cake\Datasource;
  * @method \Cake\Database\StatementInterface prepare($sql)
  * @method \Cake\Database\StatementInterface execute($query, $params = [], array $types = [])
  * @method $this enableQueryLogging($value)
+ * @method $this disableQueryLogging()
  * @method bool isQueryLoggingEnabled()
  * @method string quote($value, $type = null)
  */

+ 1 - 1
src/TestSuite/Fixture/FixtureManager.php

@@ -402,7 +402,7 @@ class FixtureManager
 
             if ($logQueries && !$this->_debug) {
                 if ($newMethods) {
-                    $db->enableQueryLogging(false);
+                    $db->disableQueryLogging();
                 } else {
                     $db->logQueries(false);
                 }

+ 1 - 1
tests/TestCase/Database/ConnectionTest.php

@@ -965,7 +965,7 @@ class ConnectionTest extends TestCase
         $this->connection->enableQueryLogging(true);
         $this->assertTrue($this->connection->isQueryLoggingEnabled());
 
-        $this->connection->enableQueryLogging(false);
+        $this->connection->disableQueryLogging();
         $this->assertFalse($this->connection->isQueryLoggingEnabled());
     }