|
@@ -414,7 +414,7 @@ discard block |
|
|
block discarded – undo |
|
414
|
414
|
$paramName = 'tdbmparam'.$counter; |
|
415
|
415
|
if (is_array($value)) { |
|
416
|
416
|
$sqlParts[] = $platform->quoteIdentifier($column).' IN (:'.$paramName.')'; |
|
417
|
|
- } else if($value === null ) { |
|
|
417
|
+ } else if ($value === null) { |
|
418
|
418
|
$sqlParts[] = $platform->quoteIdentifier($column).' IS NULL '; |
|
419
|
419
|
} else { |
|
420
|
420
|
$sqlParts[] = $platform->quoteIdentifier($column).' = :'.$paramName; |
|
@@ -425,7 +425,7 @@ discard block |
|
|
block discarded – undo |
|
425
|
425
|
} |
|
426
|
426
|
} |
|
427
|
427
|
|
|
428
|
|
- return ['(' . implode(') AND (', $sqlParts) . ')', $parameters, $counter]; |
|
|
428
|
+ return ['('.implode(') AND (', $sqlParts).')', $parameters, $counter]; |
|
429
|
429
|
} elseif ($filter_bag instanceof ResultIterator) { |
|
430
|
430
|
$subQuery = $filter_bag->_getSubQuery(); |
|
431
|
431
|
return [$subQuery, [], $counter]; |
|
@@ -1003,7 +1003,7 @@ discard block |
|
|
block discarded – undo |
|
1003
|
1003
|
|
|
1004
|
1004
|
return $this->fromCache( |
|
1005
|
1005
|
$this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
|
1006
|
|
- function () use ($tables) { |
|
|
1006
|
+ function() use ($tables) { |
|
1007
|
1007
|
return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
|
1008
|
1008
|
} |
|
1009
|
1009
|
); |
|
@@ -1051,7 +1051,7 @@ discard block |
|
|
block discarded – undo |
|
1051
|
1051
|
*/ |
|
1052
|
1052
|
public function _getRelatedTablesByInheritance(string $table): array |
|
1053
|
1053
|
{ |
|
1054
|
|
- return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
|
1054
|
+ return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
1055
|
1055
|
return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
|
1056
|
1056
|
}); |
|
1057
|
1057
|
} |
|
@@ -1140,7 +1140,7 @@ discard block |
|
|
block discarded – undo |
|
1140
|
1140
|
public function findObjects(string $mainTable, $filter = null, array $parameters = array(), $orderString = null, array $additionalTablesFetch = array(), ?int $mode = null, string $className = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
|
1141
|
1141
|
{ |
|
1142
|
1142
|
if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
|
1143
|
|
- throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
|
1143
|
+ throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1144
|
1144
|
} |
|
1145
|
1145
|
// $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
|
1146
|
1146
|
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
|
@@ -1177,7 +1177,7 @@ discard block |
|
|
block discarded – undo |
|
1177
|
1177
|
public function findObjectsFromSql(string $mainTable, string $from, $filter = null, array $parameters = array(), $orderString = null, ?int $mode = null, string $className = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
|
1178
|
1178
|
{ |
|
1179
|
1179
|
if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
|
1180
|
|
- throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
|
1180
|
+ throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1181
|
1181
|
} |
|
1182
|
1182
|
// $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
|
1183
|
1183
|
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
|
@@ -1254,7 +1254,7 @@ discard block |
|
|
block discarded – undo |
|
1254
|
1254
|
try { |
|
1255
|
1255
|
return $this->findObjectOrFail($table, $primaryKeys, [], $additionalTablesFetch, $className); |
|
1256
|
1256
|
} catch (NoBeanFoundException $exception) { |
|
1257
|
|
- $primaryKeysStringified = implode(' and ', array_map(function ($key, $value) { |
|
|
1257
|
+ $primaryKeysStringified = implode(' and ', array_map(function($key, $value) { |
|
1258
|
1258
|
return "'".$key."' = ".$value; |
|
1259
|
1259
|
}, array_keys($primaryKeys), $primaryKeys)); |
|
1260
|
1260
|
throw new NoBeanFoundException("No result found for query on table '".$table."' for ".$primaryKeysStringified, 0, $exception); |
|
@@ -1297,18 +1297,18 @@ discard block |
|
|
block discarded – undo |
|
1297
|
1297
|
if ($count > 1) { |
|
1298
|
1298
|
$additionalErrorInfos = ''; |
|
1299
|
1299
|
if (is_string($filter) && !empty($parameters)) { |
|
1300
|
|
- $additionalErrorInfos = ' for filter "' . $filter.'"'; |
|
|
1300
|
+ $additionalErrorInfos = ' for filter "'.$filter.'"'; |
|
1301
|
1301
|
foreach ($parameters as $fieldName => $parameter) { |
|
1302
|
1302
|
if (is_array($parameter)) { |
|
1303
|
|
- $value = '(' . implode(',', $parameter) . ')'; |
|
|
1303
|
+ $value = '('.implode(',', $parameter).')'; |
|
1304
|
1304
|
} else { |
|
1305
|
1305
|
$value = $parameter; |
|
1306
|
1306
|
} |
|
1307
|
|
- $additionalErrorInfos = str_replace(':' . $fieldName, var_export($value, true), $additionalErrorInfos); |
|
|
1307
|
+ $additionalErrorInfos = str_replace(':'.$fieldName, var_export($value, true), $additionalErrorInfos); |
|
1308
|
1308
|
} |
|
1309
|
1309
|
} |
|
1310
|
1310
|
$additionalErrorInfos .= '.'; |
|
1311
|
|
- throw new DuplicateRowException("Error while querying an object in table '$mainTable': More than 1 row have been returned, but we should have received at most one" . $additionalErrorInfos); |
|
|
1311
|
+ throw new DuplicateRowException("Error while querying an object in table '$mainTable': More than 1 row have been returned, but we should have received at most one".$additionalErrorInfos); |
|
1312
|
1312
|
} elseif ($count === 0) { |
|
1313
|
1313
|
return null; |
|
1314
|
1314
|
} |
|
@@ -1351,7 +1351,7 @@ discard block |
|
|
block discarded – undo |
|
1351
|
1351
|
public function findObjectsFromRawSql(string $mainTable, string $sql, array $parameters = array(), ?int $mode = null, string $className = null, string $sqlCount = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
|
1352
|
1352
|
{ |
|
1353
|
1353
|
if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
|
1354
|
|
- throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
|
1354
|
+ throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1355
|
1355
|
} |
|
1356
|
1356
|
// $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
|
1357
|
1357
|
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
|
@@ -1481,7 +1481,7 @@ discard block |
|
|
block discarded – undo |
|
1481
|
1481
|
$table1 = $fks[0]->getForeignTableName(); |
|
1482
|
1482
|
$table2 = $fks[1]->getForeignTableName(); |
|
1483
|
1483
|
|
|
1484
|
|
- $beanTables = array_map(function (DbRow $dbRow) { |
|
|
1484
|
+ $beanTables = array_map(function(DbRow $dbRow) { |
|
1485
|
1485
|
return $dbRow->_getDbTableName(); |
|
1486
|
1486
|
}, $bean->_getDbRows()); |
|
1487
|
1487
|
|