-
Notifications
You must be signed in to change notification settings - Fork 565
Expand file tree
/
Copy pathbootstrap.php
More file actions
76 lines (70 loc) · 2.62 KB
/
Copy pathbootstrap.php
File metadata and controls
76 lines (70 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
/**
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Database\Query;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
use DebugKit\DebugSql;
$hasDebugKitConfig = ConnectionManager::getConfig('debug_kit');
if (!$hasDebugKitConfig && !in_array('sqlite', PDO::getAvailableDrivers())) {
$msg = 'DebugKit not enabled. You need to either install pdo_sqlite, ' .
'or define the "debug_kit" connection name.';
Log::warning($msg);
return;
}
if (!$hasDebugKitConfig) {
ConnectionManager::setConfig('debug_kit', [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlite',
'database' => TMP . 'debug_kit.sqlite',
'encoding' => 'utf8',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
]);
}
if (!function_exists('sql')) {
/**
* Prints out the SQL statements generated by a Query object.
*
* This function returns the same variable that was passed.
* Only runs if debug mode is enabled.
*
* @param \Cake\Database\Query $query Query to show SQL statements for.
* @param bool $showValues Renders the SQL statement with bound variables.
* @param bool|null $showHtml If set to true, the method prints the debug
* data in a browser-friendly way.
* @return \Cake\Database\Query
*/
function sql(Query $query, $showValues = true, $showHtml = null)
{
return DebugSql::sql($query, $showValues, $showHtml, 1);
}
}
if (!function_exists('sqld')) {
/**
* Prints out the SQL statements generated by a Query object and dies.
*
* Only runs if debug mode is enabled.
* It will otherwise just continue code execution and ignore this function.
*
* @param \Cake\Database\Query $query Query to show SQL statements for.
* @param bool $showValues Renders the SQL statement with bound variables.
* @param bool|null $showHtml If set to true, the method prints the debug
* data in a browser-friendly way.
* @return void
*/
function sqld(Query $query, $showValues = true, $showHtml = null)
{
DebugSql::sqld($query, $showValues, $showHtml, 2);
}
}