[TYPO3-mvc] 2 Questions about repositories (logicalOr and like)
Philipp
philippwrann at gmx.at
Tue Mar 12 10:46:18 CET 2013
Hey,
I just recognized, that a logical or is build this way
(((((a=1) || a=2) || a=3) || a=4) || a=5)
Is it used to be that way?
And a other question, this is more important.... i better tell the whole story
I am writing multiple extensions at the moment, one basic called RegionalObejct and it has an aggregate RegionalObject
Then i have an Extension called Events and a new Aggregate Event, that extends the RegionalObject.
Now in im Event Repository i want to make a LIKE query on a foreign table field that is inherited from RegionalObject. Looks like this:
$this->addLikeConstraints($location, 'location.name,location.postalCode', $constraints, $query);
Note: The property location (and therefore location.name and location.postalCode) are set in RegionalObject
They are set and mapped correctly, i can access them and do stuff...
The addLikeConstraint is in my AbstractRepository, that is extended by the RegionalObjectRepository, that is extended by the EventRepository. It looks like this:
/**
* Add a like constraint to a specific field
* @param string $input The search string
* @param string $field
* @param array $constraints The constraints where to add the new constraint
* @param \TYPO3\CMS\Exbase\Persistence\QueryInterface $query The query object
*/
protected function addLikeConstraints($input, $fields, array &$constraints, \TYPO3\CMS\Extbase\Persistence\QueryInterface $query) {
if (trim($input) == '') return;
$parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',str_replace(' ',',',$input),TRUE);
$logicalOr = array();
foreach ($parts as $part) {
foreach (\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$fields,TRUE) as $field) {
array_push($logicalOr,$query->like($field,"%$part%",FALSE));
}
}
array_push($constraints,$query->logicalOr($logicalOr));
}
When i add this constraint to my constraints i get an Exception, a really weird one:
The relation information for property "location" of class "Vendor\Events\Domain\Model\Event" is missing.
Got any idea?
More information about the TYPO3-project-typo3v4mvc
mailing list