@@ -199,7 +199,7 @@ |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * @param $stmt |
|
| 202 | + * @param PDOStatement $stmt |
|
| 203 | 203 | * @param string|null $index |
| 204 | 204 | * @param bool $assoc |
| 205 | 205 | * |
@@ -161,16 +161,16 @@ |
||
| 161 | 161 | * |
| 162 | 162 | * @return void |
| 163 | 163 | */ |
| 164 | - protected function bindParams(PDOStatement &$stmt, array $values){ |
|
| 164 | + protected function bindParams(PDOStatement&$stmt, array $values){ |
|
| 165 | 165 | $param_no = 1; |
| 166 | 166 | |
| 167 | 167 | foreach($values as $v){ |
| 168 | 168 | |
| 169 | 169 | switch(gettype($v)){ |
| 170 | 170 | case 'boolean': $type = PDO::PARAM_BOOL; break; |
| 171 | - case 'integer': $type = PDO::PARAM_INT; break; |
|
| 171 | + case 'integer': $type = PDO::PARAM_INT; break; |
|
| 172 | 172 | case 'NULL' : $type = PDO::PARAM_NULL; break; |
| 173 | - default: $type = PDO::PARAM_STR; break; |
|
| 173 | + default: $type = PDO::PARAM_STR; break; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $stmt->bindValue($param_no, $v, $type); |
@@ -129,7 +129,7 @@ |
||
| 129 | 129 | * |
| 130 | 130 | * @var int |
| 131 | 131 | */ |
| 132 | - public $sqlite_flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE; |
|
| 132 | + public $sqlite_flags = SQLITE3_OPEN_READWRITE|SQLITE3_OPEN_CREATE; |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * An optional encryption key used when encrypting and decrypting an SQLite database. |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | * |
| 44 | 44 | * @return mixed|null |
| 45 | 45 | */ |
| 46 | - public function __get(string $name) { |
|
| 46 | + public function __get(string $name){ |
|
| 47 | 47 | |
| 48 | 48 | if(isset($this->array[$name])){ |
| 49 | 49 | return $this->array[$name]; |
@@ -45,6 +45,10 @@ |
||
| 45 | 45 | abstract protected function __raw(string $sql, string $index = null, bool $assoc = true); |
| 46 | 46 | abstract protected function __prepared(string $sql, array $values = [], string $index = null, bool $assoc = true); |
| 47 | 47 | abstract protected function __multi(string $sql, array $values); |
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param callable $callback |
|
| 51 | + */ |
|
| 48 | 52 | abstract protected function __multi_callback(string $sql, array $data, $callback); |
| 49 | 53 | |
| 50 | 54 | /** |
@@ -18,21 +18,21 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | trait Magic{ |
| 20 | 20 | |
| 21 | - public function __get(string $name) { |
|
| 21 | + public function __get(string $name){ |
|
| 22 | 22 | return $this->get($name); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function __set(string $name, $value) { |
|
| 25 | + public function __set(string $name, $value){ |
|
| 26 | 26 | $this->set($name, $value); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - private function get(string $name) { |
|
| 29 | + private function get(string $name){ |
|
| 30 | 30 | $method = 'magic_get_'.$name; |
| 31 | 31 | |
| 32 | 32 | return method_exists($this, $method) ? $this->$method() : null; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - private function set(string $name, $value) { |
|
| 35 | + private function set(string $name, $value){ |
|
| 36 | 36 | $method = 'magic_set_'.$name; |
| 37 | 37 | |
| 38 | 38 | if(method_exists($this, $method)){ |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | /** |
| 54 | 54 | * @param $val1 |
| 55 | 55 | * @param null $val2 |
| 56 | - * @param null $operator |
|
| 56 | + * @param string $operator |
|
| 57 | 57 | * @param bool $bind |
| 58 | 58 | * @param string $join |
| 59 | 59 | * |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | $where = []; |
| 55 | 55 | |
| 56 | 56 | foreach($this->where as $k => $v){ |
| 57 | - $last = $this->where[$k-1] ?? false; |
|
| 57 | + $last = $this->where[$k - 1] ?? false; |
|
| 58 | 58 | |
| 59 | 59 | if(in_array($v, ['AND', 'OR', 'XOR', '(', ')'], true)){ |
| 60 | 60 | $where[] = $v; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $sql .= ' ('.PHP_EOL."\t".implode(','.PHP_EOL."\t", $this->cols); |
| 37 | 37 | |
| 38 | 38 | if($this->primaryKey){ |
| 39 | - $sql .=','.PHP_EOL."\t".'PRIMARY KEY ('.$this->quote($this->primaryKey).')'; |
|
| 39 | + $sql .= ','.PHP_EOL."\t".'PRIMARY KEY ('.$this->quote($this->primaryKey).')'; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $sql .= PHP_EOL.')'; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | 'MEDIUMTEXT', 'LONGBLOB', 'LONGTEXT', 'SERIAL', 'BOOLEAN', 'UUID']; |
| 69 | 69 | |
| 70 | 70 | $field[] = (is_int($length) || is_string($length) && count(explode(',', $length)) === 2) && !in_array($type, $nolengthtypes) |
| 71 | - ? $type.'('. $length . ')' |
|
| 71 | + ? $type.'('.$length.')' |
|
| 72 | 72 | : $type; |
| 73 | 73 | |
| 74 | 74 | if($attribute){ |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param $expr1 |
| 52 | - * @param null $expr2 |
|
| 52 | + * @param string|null $expr2 |
|
| 53 | 53 | * @param null $func |
| 54 | 54 | * |
| 55 | 55 | * @return void |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if(is_string($k)){ |
| 119 | 119 | is_array($ref) |
| 120 | 120 | ? $this->addColumn($ref[0], $k, $ref[1] ?? null) |
| 121 | - : $this->addColumn($ref ,$k); |
|
| 121 | + : $this->addColumn($ref, $k); |
|
| 122 | 122 | } |
| 123 | 123 | else{ |
| 124 | 124 | is_array($ref) |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $from = $this->quote($table); |
| 141 | 141 | |
| 142 | 142 | if($ref){ |
| 143 | - $from = sprintf('%s AS %s', $this->quote($ref), $this->quote($table));// @todo: index hint |
|
| 143 | + $from = sprintf('%s AS %s', $this->quote($ref), $this->quote($table)); // @todo: index hint |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $this->from[$ref ?? $table] = $from; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $dir = strtoupper($expression[0]); |
| 212 | 212 | |
| 213 | 213 | if(in_array($dir, ['ASC', 'DESC'])){ |
| 214 | - $this->orderby[] = isset($expression[1]) ? strtoupper($expression[1]).'('.$this->quote($alias).') '.$dir : $dir; |
|
| 214 | + $this->orderby[] = isset($expression[1]) ? strtoupper($expression[1]).'('.$this->quote($alias).') '.$dir : $dir; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $dir = strtoupper($expression); |
| 220 | 220 | |
| 221 | 221 | if(in_array($dir, ['ASC', 'DESC'])){ |
| 222 | - $this->orderby[] = $this->quote($alias).' '.$dir; |
|
| 222 | + $this->orderby[] = $this->quote($alias).' '.$dir; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $sql = 'SELECT '; |
| 266 | 266 | $sql .= $this->distinct ? 'DISTINCT ' : ''; |
| 267 | 267 | $sql .= 'COUNT(*) AS '.$this->quote('count'); |
| 268 | - $sql .= 'FROM '.implode($glue , $this->from); |
|
| 268 | + $sql .= 'FROM '.implode($glue, $this->from); |
|
| 269 | 269 | $sql .= $this->_getWhere(); |
| 270 | 270 | $sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : ''; |
| 271 | 271 | |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | |
| 37 | 37 | $sql = 'SELECT '; |
| 38 | 38 | $sql .= $this->distinct ? 'DISTINCT ' : ''; |
| 39 | - $sql .= !empty($this->cols) ? implode($glue , $this->cols).PHP_EOL : '* '; |
|
| 40 | - $sql .= 'FROM '.implode($glue , $this->from); |
|
| 39 | + $sql .= !empty($this->cols) ? implode($glue, $this->cols).PHP_EOL : '* '; |
|
| 40 | + $sql .= 'FROM '.implode($glue, $this->from); |
|
| 41 | 41 | $sql .= $this->_getWhere(); |
| 42 | 42 | $sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : ''; |
| 43 | 43 | $sql .= !empty($this->orderby) ? PHP_EOL.'ORDER BY '.implode($glue, $this->orderby) : ''; |