@@ -52,7 +52,7 @@ |
||
52 | 52 | $this->connect(); |
53 | 53 | $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql); |
54 | 54 | if ($statement === false) { |
55 | - throw new DBException('Prepare error: ' . \ibase_errmsg()); |
|
55 | + throw new DBException('Prepare error: '.\ibase_errmsg()); |
|
56 | 56 | } |
57 | 57 | return new Statement( |
58 | 58 | $statement, |
@@ -24,28 +24,28 @@ |
||
24 | 24 | foreach ($data as $i => $v) { |
25 | 25 | switch (gettype($v)) { |
26 | 26 | case 'boolean': |
27 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_BOOL); |
|
27 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_BOOL); |
|
28 | 28 | break; |
29 | 29 | case 'integer': |
30 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_INT); |
|
30 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_INT); |
|
31 | 31 | break; |
32 | 32 | case 'NULL': |
33 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_NULL); |
|
33 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_NULL); |
|
34 | 34 | break; |
35 | 35 | case 'double': |
36 | - $this->statement->bindValue($i+1, $v); |
|
36 | + $this->statement->bindValue($i + 1, $v); |
|
37 | 37 | break; |
38 | 38 | default: |
39 | 39 | // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax: |
40 | 40 | // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ? |
41 | 41 | if (is_resource($v) && get_resource_type($v) === 'stream') { |
42 | - $this->statement->bindParam($i+1, $v, \PDO::PARAM_LOB); |
|
42 | + $this->statement->bindParam($i + 1, $v, \PDO::PARAM_LOB); |
|
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | if (!is_string($data[$i])) { |
46 | 46 | $data[$i] = serialize($data[$i]); |
47 | 47 | } |
48 | - $this->statement->bindValue($i+1, $v); |
|
48 | + $this->statement->bindValue($i + 1, $v); |
|
49 | 49 | break; |
50 | 50 | } |
51 | 51 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | } |
56 | 56 | public function next() |
57 | 57 | { |
58 | - $this->fetched ++; |
|
58 | + $this->fetched++; |
|
59 | 59 | $this->last = $this->statement->fetch(\PDO::FETCH_ASSOC); |
60 | 60 | } |
61 | 61 | public function valid() |
@@ -44,7 +44,7 @@ |
||
44 | 44 | isset($this->connection['opts']) ? $this->connection['opts'] : [] |
45 | 45 | ); |
46 | 46 | } catch (\PDOException $e) { |
47 | - throw new DBException('Connect error: ' . $e->getMessage()); |
|
47 | + throw new DBException('Connect error: '.$e->getMessage()); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $instance->setDefault($data['default']); |
48 | 48 | } |
49 | 49 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
50 | - $temp = array_map(function ($v) { |
|
50 | + $temp = array_map(function($v) { |
|
51 | 51 | return str_replace("''", "'", $v); |
52 | 52 | }, explode("','", substr($instance->getType(), 6, -2))); |
53 | 53 | $instance->setValues($temp); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function setPrimaryKey($column) : Table |
79 | 79 | { |
80 | 80 | if (!is_array($column)) { |
81 | - $column = [ $column ]; |
|
81 | + $column = [$column]; |
|
82 | 82 | } |
83 | 83 | $this->data['primary'] = $column; |
84 | 84 | return $this; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | if (!isset($name)) { |
168 | - $name = $toTable->getName() . '_' . implode('_', array_keys($keymap)); |
|
168 | + $name = $toTable->getName().'_'.implode('_', array_keys($keymap)); |
|
169 | 169 | } |
170 | 170 | $this->addRelation(new TableRelation( |
171 | 171 | $name, |
@@ -83,7 +83,7 @@ |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | if (!$this->statement->execute()) { |
86 | - throw new DBException('Prepared execute error: ' . $this->statement->error); |
|
86 | + throw new DBException('Prepared execute error: '.$this->statement->error); |
|
87 | 87 | } |
88 | 88 | return new Result($this->statement); |
89 | 89 | } |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | $connection['name'] = $connectionString; |
76 | 76 | $connection['type'] = isset($aliases[$connection['type']]) ? |
77 | - $aliases[$connection['type']] : |
|
78 | - $connection['type']; |
|
77 | + $aliases[$connection['type']] : $connection['type']; |
|
79 | 78 | $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver'; |
80 | 79 | return new $tmp($connection); |
81 | 80 | } |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | $new = ''; |
96 | 95 | $par = array_values($par); |
97 | 96 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
98 | - $par = [ $par ]; |
|
97 | + $par = [$par]; |
|
99 | 98 | } |
100 | 99 | $parts = explode('??', $sql); |
101 | 100 | $index = 0; |
@@ -105,7 +104,7 @@ discard block |
||
105 | 104 | $index += count($tmp) - 1; |
106 | 105 | if (isset($par[$index])) { |
107 | 106 | if (!is_array($par[$index])) { |
108 | - $par[$index] = [ $par[$index] ]; |
|
107 | + $par[$index] = [$par[$index]]; |
|
109 | 108 | } |
110 | 109 | $params = $par[$index]; |
111 | 110 | array_splice($par, $index, 1, $params); |
@@ -113,7 +112,7 @@ discard block |
||
113 | 112 | $new .= implode(',', array_fill(0, count($params), '?')); |
114 | 113 | } |
115 | 114 | } |
116 | - return [ $new, $par ]; |
|
115 | + return [$new, $par]; |
|
117 | 116 | } |
118 | 117 | /** |
119 | 118 | * Run a query (prepare & execute). |
@@ -145,7 +144,7 @@ discard block |
||
145 | 144 | { |
146 | 145 | $coll = Collection::from($this->query($sql, $par)); |
147 | 146 | if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) { |
148 | - $coll->map(function ($v) use ($keys) { |
|
147 | + $coll->map(function($v) use ($keys) { |
|
149 | 148 | $new = []; |
150 | 149 | foreach ($v as $k => $vv) { |
151 | 150 | $new[call_user_func($keys, $k)] = $vv; |
@@ -154,13 +153,13 @@ discard block |
||
154 | 153 | }); |
155 | 154 | } |
156 | 155 | if ($key !== null) { |
157 | - $coll->mapKey(function ($v) use ($key) { return $v[$key]; }); |
|
156 | + $coll->mapKey(function($v) use ($key) { return $v[$key]; }); |
|
158 | 157 | } |
159 | 158 | if ($skip) { |
160 | - $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; }); |
|
159 | + $coll->map(function($v) use ($key) { unset($v[$key]); return $v; }); |
|
161 | 160 | } |
162 | 161 | if ($opti) { |
163 | - $coll->map(function ($v) { return count($v) === 1 ? current($v) : $v; }); |
|
162 | + $coll->map(function($v) { return count($v) === 1 ? current($v) : $v; }); |
|
164 | 163 | } |
165 | 164 | return $coll; |
166 | 165 | } |
@@ -233,8 +232,7 @@ discard block |
||
233 | 232 | public function definition(string $table, bool $detectRelations = true) : Table |
234 | 233 | { |
235 | 234 | return isset($this->tables[$table]) ? |
236 | - $this->tables[$table] : |
|
237 | - $this->driver->table($table, $detectRelations); |
|
235 | + $this->tables[$table] : $this->driver->table($table, $detectRelations); |
|
238 | 236 | } |
239 | 237 | /** |
240 | 238 | * Parse all tables from the database. |
@@ -251,12 +249,12 @@ discard block |
||
251 | 249 | */ |
252 | 250 | public function getSchema($asPlainArray = true) |
253 | 251 | { |
254 | - return !$asPlainArray ? $this->tables : array_map(function ($table) { |
|
252 | + return !$asPlainArray ? $this->tables : array_map(function($table) { |
|
255 | 253 | return [ |
256 | 254 | 'name' => $table->getName(), |
257 | 255 | 'pkey' => $table->getPrimaryKey(), |
258 | 256 | 'comment' => $table->getComment(), |
259 | - 'columns' => array_map(function ($column) { |
|
257 | + 'columns' => array_map(function($column) { |
|
260 | 258 | return [ |
261 | 259 | 'name' => $column->getName(), |
262 | 260 | 'type' => $column->getType(), |
@@ -266,13 +264,13 @@ discard block |
||
266 | 264 | 'nullable' => $column->isNullable() |
267 | 265 | ]; |
268 | 266 | }, $table->getFullColumns()), |
269 | - 'relations' => array_map(function ($rel) { |
|
267 | + 'relations' => array_map(function($rel) { |
|
270 | 268 | $relation = clone $rel; |
271 | 269 | $relation->table = $relation->table->getName(); |
272 | 270 | if ($relation->pivot) { |
273 | 271 | $relation->pivot = $relation->pivot->getName(); |
274 | 272 | } |
275 | - return (array)$relation; |
|
273 | + return (array) $relation; |
|
276 | 274 | }, $table->getRelations()) |
277 | 275 | ]; |
278 | 276 | }, $this->tables); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | } |
75 | 75 | public function next() |
76 | 76 | { |
77 | - $this->fetched ++; |
|
77 | + $this->fetched++; |
|
78 | 78 | $temp = \odbc_fetch_row($this->statement); |
79 | 79 | if (!$temp) { |
80 | 80 | $this->last = false; |
@@ -18,6 +18,9 @@ |
||
18 | 18 | protected $fetched = -1; |
19 | 19 | protected $iid = null; |
20 | 20 | |
21 | + /** |
|
22 | + * @param resource $statement |
|
23 | + */ |
|
21 | 24 | public function __construct($statement, $data, $iid, $charIn = null, $charOut = null) |
22 | 25 | { |
23 | 26 | $this->statement = $statement; |