-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.php
88 lines (78 loc) · 1.64 KB
/
globals.php
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
77
78
79
80
81
82
83
84
85
86
87
88
<?php
use yii\helpers\VarDumper;
define('IS_CLI', 'cli' === PHP_SAPI);
if (!function_exists('d')) {
/**
* Dump the passed variables and end the script.
*
* @param mixed
*/
function d()
{
array_map(function ($x) {
echo !IS_CLI ? '<pre>' : '';
var_dump($x);
echo !IS_CLI ? '</pre>' : '';
}, func_get_args());
}
}
if (!function_exists('dd')) {
/**
* Dump the passed variables and end the script.
*
* @param mixed
*/
function dd()
{
array_map(function ($x) {
echo !IS_CLI ? '<pre>' : '';
var_dump($x);
echo !IS_CLI ? '</pre>' : '';
}, func_get_args());
die(1);
}
}
if (!function_exists('ed')) {
/**
* @param string $var
*/
function ed($var)
{
echo $var;
die(1);
}
}
if (!function_exists('vdd')) {
/**
* Dump the passed variables and end the script.
*
* @param mixed
*/
function vdd()
{
array_map(function ($x, $depth = 10, $highlight = true) {
VarDumper::dump($x, $depth, $highlight);
}, func_get_args());
die(1);
}
}
/**
* @param \yii\db\Query $select
* @param \yii\db\Connection $db
* @return string
*/
function getsql(\yii\db\Query $select, $db = null)
{
if ($db === null) {
$db = Yii::$app->getDb();
}
return $select->prepare(Yii::$app->db->queryBuilder)->createCommand($db)->rawSql;
}
/**
* @param \yii\db\Query $select
* @param \yii\db\Connection $db
*/
function ddsql(\yii\db\Query $select, $db = null)
{
dd(getsql($select, $db));
}