|
@@ 1245-1257 (lines=13) @@
|
| 1242 |
|
* |
| 1243 |
|
* @throws TDBMException |
| 1244 |
|
*/ |
| 1245 |
|
public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null) |
| 1246 |
|
{ |
| 1247 |
|
$objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className); |
| 1248 |
|
$page = $objects->take(0, 2); |
| 1249 |
|
$count = $page->count(); |
| 1250 |
|
if ($count > 1) { |
| 1251 |
|
throw new DuplicateRowException("Error while querying an object for table '$mainTable': More than 1 row have been returned, but we should have received at most one."); |
| 1252 |
|
} elseif ($count === 0) { |
| 1253 |
|
return; |
| 1254 |
|
} |
| 1255 |
|
|
| 1256 |
|
return $page[0]; |
| 1257 |
|
} |
| 1258 |
|
|
| 1259 |
|
/** |
| 1260 |
|
* Returns a unique bean (or null) according to the filters passed in parameter. |
|
@@ 1272-1284 (lines=13) @@
|
| 1269 |
|
* |
| 1270 |
|
* @throws TDBMException |
| 1271 |
|
*/ |
| 1272 |
|
public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null) |
| 1273 |
|
{ |
| 1274 |
|
$objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className); |
| 1275 |
|
$page = $objects->take(0, 2); |
| 1276 |
|
$count = $page->count(); |
| 1277 |
|
if ($count > 1) { |
| 1278 |
|
throw new DuplicateRowException("Error while querying an object for table '$mainTable': More than 1 row have been returned, but we should have received at most one."); |
| 1279 |
|
} elseif ($count === 0) { |
| 1280 |
|
return; |
| 1281 |
|
} |
| 1282 |
|
|
| 1283 |
|
return $page[0]; |
| 1284 |
|
} |
| 1285 |
|
|
| 1286 |
|
/** |
| 1287 |
|
* Returns a unique bean according to the filters passed in parameter. |