@@ -331,14 +331,14 @@ |
||
| 331 | 331 | public function getQuery() |
| 332 | 332 | { |
| 333 | 333 | return 'SELECT ' |
| 334 | - . (!empty($this->modifier) ? implode(' ', $this->modifier) . ' ' : '') |
|
| 335 | - . ($this->columns ? implode(',', $this->columns) : '*') |
|
| 336 | - . ' FROM ' . $this->tableName . ($this->alias ? ' AS ' . $this->alias : '') |
|
| 337 | - . (!empty($this->joins) ? ' ' . implode(' ', $this->joins) : '') |
|
| 338 | - . (!empty($this->where) ? ' WHERE ' . implode(' ', $this->where) : '') |
|
| 339 | - . (!empty($this->groupBy) ? ' GROUP BY ' . implode(',', $this->groupBy) : '') |
|
| 340 | - . (!empty($this->orderBy) ? ' ORDER BY ' . implode(',', $this->orderBy) : '') |
|
| 341 | - . ($this->limit ? ' LIMIT ' . $this->limit . ($this->offset ? ' OFFSET ' . $this->offset : '') : ''); |
|
| 334 | + . (!empty($this->modifier) ? implode(' ', $this->modifier) . ' ' : '') |
|
| 335 | + . ($this->columns ? implode(',', $this->columns) : '*') |
|
| 336 | + . ' FROM ' . $this->tableName . ($this->alias ? ' AS ' . $this->alias : '') |
|
| 337 | + . (!empty($this->joins) ? ' ' . implode(' ', $this->joins) : '') |
|
| 338 | + . (!empty($this->where) ? ' WHERE ' . implode(' ', $this->where) : '') |
|
| 339 | + . (!empty($this->groupBy) ? ' GROUP BY ' . implode(',', $this->groupBy) : '') |
|
| 340 | + . (!empty($this->orderBy) ? ' ORDER BY ' . implode(',', $this->orderBy) : '') |
|
| 341 | + . ($this->limit ? ' LIMIT ' . $this->limit . ($this->offset ? ' OFFSET ' . $this->offset : '') : ''); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** {@inheritdoc} */ |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $statement = 'INSERT INTO ' . $table . ' (' . implode(',', $cols) . ') ' . |
| 143 | - 'VALUES (' . implode('),(', $associations) . ')'; |
|
| 143 | + 'VALUES (' . implode('),(', $associations) . ')'; |
|
| 144 | 144 | $entityManager->getConnection()->query($statement); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $where[] = $entityManager->escapeIdentifier($fkCol) . ' = ' . |
| 165 | - $entityManager->escapeValue($value); |
|
| 165 | + $entityManager->escapeValue($value); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | foreach ($entities as $entity) { |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $condition[] = $entityManager->escapeIdentifier($fkCol) . ' = ' . |
| 182 | - $entityManager->escapeValue($value); |
|
| 182 | + $entityManager->escapeValue($value); |
|
| 183 | 183 | } |
| 184 | 184 | $where[] = implode(' AND ', $condition); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $statement = 'DELETE FROM ' . $table . ' WHERE ' . array_shift($where) . ' ' . |
| 188 | - 'AND (' . implode(' OR ', $where) . ')'; |
|
| 188 | + 'AND (' . implode(' OR ', $where) . ')'; |
|
| 189 | 189 | $entityManager->getConnection()->query($statement); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -297,7 +297,7 @@ |
||
| 297 | 297 | $this->columns = ['t0.*']; |
| 298 | 298 | $this->modifier = ['DISTINCT']; |
| 299 | 299 | |
| 300 | - return (int)$this->entityManager->getConnection()->query($query)->fetchColumn(); |
|
| 300 | + return (int) $this->entityManager->getConnection()->query($query)->fetchColumn(); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $rawColumns = $result->fetchAll(\PDO::FETCH_ASSOC); |
| 58 | 58 | |
| 59 | 59 | if (count($rawColumns) === 0) { |
| 60 | - throw new Exception('Unknown table ' . $table); |
|
| 60 | + throw new Exception('Unknown table ' . $table); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $hasMultiplePrimaryKey = $this->hasMultiplePrimaryKey($rawColumns); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @param Entity $entity |
| 390 | 390 | * @param bool $useAutoIncrement |
| 391 | - * @return mixed |
|
| 391 | + * @return boolean |
|
| 392 | 392 | * @internal |
| 393 | 393 | */ |
| 394 | 394 | public function insert(Entity $entity, $useAutoIncrement = true) |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * Without $primaryKey it creates an entityFetcher and returns this. |
| 463 | 463 | * |
| 464 | - * @param string|Entity $class The entity class you want to fetch |
|
| 464 | + * @param string $class The entity class you want to fetch |
|
| 465 | 465 | * @param mixed $primaryKey The primary key of the entity you want to fetch |
| 466 | 466 | * @return Entity|EntityFetcher |
| 467 | 467 | * @throws IncompletePrimaryKey |
@@ -10,8 +10,6 @@ |
||
| 10 | 10 | use ORM\Exception\InvalidConfiguration; |
| 11 | 11 | use ORM\Exception\NoConnection; |
| 12 | 12 | use ORM\Exception\NoEntity; |
| 13 | -use ORM\Exception\NotScalar; |
|
| 14 | -use ORM\Exception\UnsupportedDriver; |
|
| 15 | 13 | |
| 16 | 14 | /** |
| 17 | 15 | * The EntityManager that manages the instances of Entities. |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $statement = 'UPDATE ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 145 | - 'SET ' . implode(',', $set) . ' ' . |
|
| 146 | - 'WHERE ' . implode(' AND ', $where); |
|
| 145 | + 'SET ' . implode(',', $set) . ' ' . |
|
| 146 | + 'WHERE ' . implode(' AND ', $where); |
|
| 147 | 147 | $this->entityManager->getConnection()->query($statement); |
| 148 | 148 | |
| 149 | 149 | return true; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $statement = 'DELETE FROM ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 170 | - 'WHERE ' . implode(' AND ', $where); |
|
| 170 | + 'WHERE ' . implode(' AND ', $where); |
|
| 171 | 171 | $this->entityManager->getConnection()->query($statement); |
| 172 | 172 | |
| 173 | 173 | return true; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | }, array_values($data)); |
| 257 | 257 | |
| 258 | 258 | $statement = 'INSERT INTO ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 259 | - '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 259 | + '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 260 | 260 | |
| 261 | 261 | return $statement; |
| 262 | 262 | } |
@@ -91,8 +91,7 @@ |
||
| 91 | 91 | |
| 92 | 92 | $definition['column_name'] = $rawColumn['Field']; |
| 93 | 93 | $definition['is_nullable'] = $rawColumn['Null'] === 'YES'; |
| 94 | - $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : |
|
| 95 | - ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 94 | + $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 96 | 95 | $definition['character_maximum_length'] = null; |
| 97 | 96 | $definition['datetime_precision'] = null; |
| 98 | 97 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | $result = $this->entityManager->getConnection()->query($query->getQuery()); |
| 73 | 73 | $rawColumns = $result->fetchAll(PDO::FETCH_ASSOC); |
| 74 | 74 | if (count($rawColumns) === 0) { |
| 75 | - throw new Exception('Unknown table ' . $schemaTable); |
|
| 75 | + throw new Exception('Unknown table ' . $schemaTable); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $cols = array_map(function ($columnDefinition) { |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | public function validate($value) |
| 19 | 19 | { |
| 20 | 20 | if (!is_string($value)) { |
| 21 | - return new NoString([ 'type' => 'set' ]); |
|
| 21 | + return new NoString(['type' => 'set']); |
|
| 22 | 22 | } else { |
| 23 | 23 | $values = explode(',', $value); |
| 24 | 24 | foreach ($values as $value) { |
| 25 | 25 | if (!in_array($value, $this->allowedValues)) { |
| 26 | - return new NotAllowed([ 'value' => $value, 'type' => 'set' ]); |
|
| 26 | + return new NotAllowed(['value' => $value, 'type' => 'set']); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |