@@ 1369-1381 (lines=13) @@ | ||
1366 | * |
|
1367 | * @throws TDBMException |
|
1368 | */ |
|
1369 | public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null) |
|
1370 | { |
|
1371 | $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className); |
|
1372 | $page = $objects->take(0, 2); |
|
1373 | $count = $page->count(); |
|
1374 | if ($count > 1) { |
|
1375 | 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."); |
|
1376 | } elseif ($count === 0) { |
|
1377 | return; |
|
1378 | } |
|
1379 | ||
1380 | return $page[0]; |
|
1381 | } |
|
1382 | ||
1383 | /** |
|
1384 | * Returns a unique bean (or null) according to the filters passed in parameter. |
|
@@ 1396-1408 (lines=13) @@ | ||
1393 | * |
|
1394 | * @throws TDBMException |
|
1395 | */ |
|
1396 | public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null) |
|
1397 | { |
|
1398 | $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className); |
|
1399 | $page = $objects->take(0, 2); |
|
1400 | $count = $page->count(); |
|
1401 | if ($count > 1) { |
|
1402 | 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."); |
|
1403 | } elseif ($count === 0) { |
|
1404 | return; |
|
1405 | } |
|
1406 | ||
1407 | return $page[0]; |
|
1408 | } |
|
1409 | ||
1410 | /** |
|
1411 | * Returns a unique bean according to the filters passed in parameter. |