nystudio107 /
craft-connect
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Connect plugin for Craft CMS 3.x |
||
| 4 | * |
||
| 5 | * Allows you to connect to external databases and perform db queries |
||
| 6 | * |
||
| 7 | * @link https://nystudio107.com/ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 8 | * @copyright Copyright (c) 2018 nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 9 | */ |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | namespace nystudio107\connect\db; |
||
| 12 | |||
| 13 | use yii\db\Connection; |
||
| 14 | |||
| 15 | /** |
||
|
0 ignored issues
–
show
|
|||
| 16 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 17 | * @package Connect |
||
|
0 ignored issues
–
show
|
|||
| 18 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 19 | */ |
||
|
0 ignored issues
–
show
|
|||
| 20 | class Query extends \yii\db\Query |
||
| 21 | { |
||
| 22 | // Public Properties |
||
| 23 | // ========================================================================= |
||
| 24 | |||
| 25 | /** |
||
|
0 ignored issues
–
show
|
|||
| 26 | * @var Connection the database connections |
||
| 27 | */ |
||
| 28 | public $db = null; |
||
| 29 | |||
| 30 | // Public Methods |
||
| 31 | // ========================================================================= |
||
| 32 | |||
| 33 | /** |
||
|
0 ignored issues
–
show
|
|||
| 34 | * @inheritdoc |
||
| 35 | */ |
||
|
0 ignored issues
–
show
|
|||
| 36 | public function createCommand($db = null) |
||
| 37 | { |
||
| 38 | return parent::createCommand($db ?? $this->db); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
|
0 ignored issues
–
show
|
|||
| 42 | * @inheritdoc |
||
| 43 | */ |
||
|
0 ignored issues
–
show
|
|||
| 44 | public function batch($batchSize = 100, $db = null) |
||
| 45 | { |
||
| 46 | return parent::batch($batchSize, $db ?? $this->db); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
|
0 ignored issues
–
show
|
|||
| 50 | * @inheritdoc |
||
| 51 | */ |
||
|
0 ignored issues
–
show
|
|||
| 52 | public function each($batchSize = 100, $db = null) |
||
| 53 | { |
||
| 54 | return parent::each($batchSize, $db ?? $this->db); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
|
0 ignored issues
–
show
|
|||
| 58 | * @inheritdoc |
||
| 59 | */ |
||
|
0 ignored issues
–
show
|
|||
| 60 | public function all($db = null) |
||
| 61 | { |
||
| 62 | return parent::all($db ?? $this->db); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
|
0 ignored issues
–
show
|
|||
| 66 | * @inheritdoc |
||
| 67 | */ |
||
|
0 ignored issues
–
show
|
|||
| 68 | public function one($db = null) |
||
| 69 | { |
||
| 70 | return parent::one($db ?? $this->db); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
|
0 ignored issues
–
show
|
|||
| 74 | * @inheritdoc |
||
| 75 | */ |
||
|
0 ignored issues
–
show
|
|||
| 76 | public function scalar($db = null) |
||
| 77 | { |
||
| 78 | return parent::scalar($db ?? $this->db); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
|
0 ignored issues
–
show
|
|||
| 82 | * @inheritdoc |
||
| 83 | */ |
||
|
0 ignored issues
–
show
|
|||
| 84 | public function column($db = null) |
||
| 85 | { |
||
| 86 | return parent::column($db ?? $this->db); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
|
0 ignored issues
–
show
|
|||
| 90 | * @inheritdoc |
||
| 91 | */ |
||
|
0 ignored issues
–
show
|
|||
| 92 | public function count($q = '*', $db = null) |
||
| 93 | { |
||
| 94 | return parent::count($q, $db ?? $this->db); |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
|
0 ignored issues
–
show
|
|||
| 98 | * @inheritdoc |
||
| 99 | */ |
||
|
0 ignored issues
–
show
|
|||
| 100 | public function sum($q, $db = null) |
||
| 101 | { |
||
| 102 | return parent::sum($q, $db ?? $this->db); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
|
0 ignored issues
–
show
|
|||
| 106 | * @inheritdoc |
||
| 107 | */ |
||
|
0 ignored issues
–
show
|
|||
| 108 | public function average($q, $db = null) |
||
| 109 | { |
||
| 110 | return parent::average($q, $db ?? $this->db); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
|
0 ignored issues
–
show
|
|||
| 114 | * @inheritdoc |
||
| 115 | */ |
||
|
0 ignored issues
–
show
|
|||
| 116 | public function min($q, $db = null) |
||
| 117 | { |
||
| 118 | return parent::min($q, $db ?? $this->db); |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
|
0 ignored issues
–
show
|
|||
| 122 | * @inheritdoc |
||
| 123 | */ |
||
|
0 ignored issues
–
show
|
|||
| 124 | public function max($q, $db = null) |
||
| 125 | { |
||
| 126 | return parent::max($q, $db ?? $this->db); |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
|
0 ignored issues
–
show
|
|||
| 130 | * @inheritdoc |
||
| 131 | */ |
||
|
0 ignored issues
–
show
|
|||
| 132 | public function exists($db = null) |
||
| 133 | { |
||
| 134 | return parent::exists($db ?? $this->db); |
||
| 135 | } |
||
| 136 | } |
||
| 137 |