Warning: Can't synchronize with the repository (No changeset 152 in the repository). Look in the Trac log for more information.

Ticket #14 (assigned enhancement)

Opened 20 months ago

Last modified 18 months ago

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

Changed 20 months ago by jkleijn

  • status changed from new to assigned
  • estimatedhours set to 0.0
  • billable unset

Changed 20 months ago by jkleijn

  • estimatedhours changed from 0.0 to 10.0
  • billable set

Changed 19 months ago by jkleijn

  • hours set to 0
  • estimatedhours changed from 10.0 to 24.0
  • description modified (diff)
  • milestone changed from 0.2 to 0.3

Changed 19 months ago by jkleijn

  • description modified (diff)

Changed 19 months ago by jkleijn

  • description modified (diff)

Changed 18 months ago by jkleijn

  • milestone changed from 0.2 to 0.3
Note: See TracTickets for help on using tickets.