Feature #1677

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

Added by Bastian Waidelich over 11 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Could have
Category:
Persistence
Target version:
-
Start date:
2008-10-11
Due date:
% Done:

100%

PHP Version:
Has patch:
Complexity:

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 base repository Resolved 2009-02-10

History

#1 Updated by Karsten Dambekalns over 11 years ago

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

#2 Updated by Karsten Dambekalns over 11 years ago

  • Category set to Persistence

#3 Updated by Karsten Dambekalns about 11 years ago

  • Status changed from New to Resolved
  • Assignee 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