Ticket #14 (assigned enhancement)
Complicated automated finder methods
| Reported by: | jkleijn | Owned by: | jkleijn |
|---|---|---|---|
| Priority: | major | Milestone: | 0.3 |
| Component: | Phreamp_Data | Severity: | Major |
| Keywords: | Cc: | ||
| Estimated Number of Hours: | 24.0 | Add Hours to Ticket: | 0 |
| Billable?: | yes | Total Hours: |
Description (last modified by jkleijn) (diff)
Currently Phreamp_Data_Mapper_Abstract only supports basic property search. This needs to be expanded to support finding by a property from a different class, as well more complex conditions. Probably needs to be abstracted into a separate object hierarchy.
An automated finder should use a data request object.
Stuff that needs to be matched/supported:
'WHERE BETWEEN .. AND'
<?php $objects = $session->findClassNameByPropertyWhereBetween('2009-01-01', '2010-01-01');
'WHERE IN ()'
<?php $session->findClassNameByPropertyWhereIn(array(1, 2, 3));
'NOT'
<?php $session->findClassNameByPropertyWhereNot('do not select me'); $session->findClassNameByPropertyWhereNotIn(array(1, 2, 3)); $session->findClassNameByPropertyWhereNotBetween('2009-01-01', '2010-01-01');
Building a request object:
<?php $request = $session->getNewRequest('ClassName'); $request->setJoinMode('AggregateClass', Phreamp_Data_Join:MODE_ALWAYS); $objects = $session->fetch( $request->where() ->not() ->in(array(1, 2, 3)) );
<?php $request = $session->getNewRequest('ClassName'); $request->setJoinMode('*', Phreamp_Data_Join:MODE_NEVER); $objects = request->where() ->not() ->between('2009-01-01', $request->expr('NOW()')) ->or() ->valueOf('_propertyName', 'always fetch me') ->fetch();
A finder is actually a request (similar to above):
<?php $this->findClassNameWhereNotBetweenOrValueOfPropertyName(array(1, 2), 'always fetch me'); //'by' same as 'ValueOfPropertyName' in 'where clause'. $this->findClassNameByPropertyNameWhereNotBetween(array(1, 2), 'always fetch me');
Support for 'count' instead of 'find':
<?php $count = $session->countClassNameByPropertyWhereNot('do not select me'); $request = $session->getNewCountRequest('ClassName'); $count = $session->fetch( $request->where() ->not() ->in(array(1, 2, 3)) );
Change History
Note: See
TracTickets for help on using
tickets.
