Feature #1677

Query: add convenience method returning the first object of a result set

Added by Bastian Waidelich almost 7 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2008-10-11
Priority:Could have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Persistence
Target version:-
PHP Version: Complexity:
Has patch:

Description

To retrieve one single object from a repository, one has to do something like this currently:

$objects = $query->execute();
if (count($objects) < 1) {
  return NULL;
}
return $objects[0];

Something like a "fetchOne()"-method in F3::TYPO3CR::Query::Query would be helpful:

$query->execute()->fetchOne();

or probably more like that

$query->fetchOne();

this could also set the limit to 1 to improve performance.


Related issues

related to TYPO3.Flow - Feature #2603: Implement magic findBy*() and findOneBy*() methods in the... Resolved 2009-02-10

History

#1 Updated by Karsten Dambekalns almost 7 years ago

  • Project changed from TYPO3.TYPO3CR to TYPO3.Flow
  • Category deleted (Query handling)

#2 Updated by Karsten Dambekalns almost 7 years ago

  • Category set to Persistence

#3 Updated by Karsten Dambekalns over 6 years ago

  • Status changed from New to Resolved
  • Assigned To set to Karsten Dambekalns
  • % Done changed from 0 to 100

I consider this resolved as of changeset r1890 by Robert Lemke.

Also available in: Atom PDF