$this->connection->
query('SELECT [age] FROM {test} WHERE [name] = :name',
[':name' => 'Ringo'
])->
fetchCol();
// Trigger a call that does not have file in the backtrace.
call_user_func_array([Database::
getConnection(), 'query'
],
['SELECT [age] FROM {test} WHERE [name] = :name',
[':name' => 'Ringo'
]])->
fetchCol();
$queries = Database::
getLog('testing', 'default'
);
$this->
assertCount(3,
$queries, 'Correct number of queries recorded.'
);
foreach ($queries as $query) { $this->
assertEquals(__FUNCTION__,
$query['caller'
]['function'
], 'Correct function in query log.'
);
$this->
assertIsFloat($query['start'
]);
$this->
assertGreaterThanOrEqual($start,
$query['start'
]);
} } /**
* Tests that we can run two logs in parallel.
*/
public function testEnableMultiLogging() { Database::
startLog('testing1'
);
$this->connection->
query('SELECT [name] FROM {test} WHERE [age] > :age',
[':age' => 25
])->
fetchCol();