Feature #31803
Accessing Query Builder
Status: | Resolved | Start date: | 2011-11-14 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 100% |
|
Category: | Persistence | |||
Target version: | - | |||
PHP Version: | 5.3 | Complexity: | ||
Has patch: | No |
Description
Hi Folks,
i need a special query with additional fields in select statement and a HAVING.
for example:
$query = "SELECT ort, plz, (
".$radius." * SQRT) *
cos(".$rad_b.") * (sin(RADIANS) *
sin(".$rad_l.") + cos(RADIANS) *
cos(".$rad_l.")) - sin(RADIANS) * sin(".$rad_b.")))) AS Distance
FROM plz Having Distance <= ".$umkreis."
ORDER BY Distance
";
as far as i know i can add special fields with:
$this->queryBuilder()->add(); by the queryBuilder of \TYPO3\FLOW3\Persistence\Doctrine\Query.
But the query builder is protected and there is no getter for it.
It is a good or a bad idea to add public function getQueryBuilder into the Query Class to enable a usage like:
$this->query->getQueryBuilder->add('select'...)?
if anybody could tell me how to do the query above, please tell me.
thanks a lot!
carsten
History
#1 Updated by Carsten Bleicker over 3 years ago
if queryBuilder is accessible the whole power of doctrine could be used by default in repositories.
for example:
$this->query->getQueryBuilder()->join()
or $this->query->getQueryBuilder()->having().
but in case i make it public and build the guery as above the CountWalker throws exceptions because some vars missing in $this->_getQueryComponents()
if something is in select wich has nothing to do with properties of the model.
i dont know exactly. but is doctrine configuration also available somewhere?
if it isnt it would be also usefull to do to register some functions for Doctrine\ORM\Query\AST\Functions.
for example:
$query->getEntityManager()->getConfiguration()->addCustomNumericFunction('ACOS','BLEICKER\Social\Persistence\Doctrine\ORM\Query\AST\Functions\AcosFunction');
#2 Updated by Karsten Dambekalns over 3 years ago
- Target version deleted (
1.0.1)
#3 Updated by Karsten Dambekalns over 3 years ago
- Tracker changed from Bug to Feature
#4 Updated by Franz Kugelmann over 1 year ago
Just stumbled upon a snippet for such needs from Bastian:
https://gist.github.com/bwaidelich/5433673
#5 Updated by Karsten Dambekalns 5 months ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
This has been solved as a side effect of FLOW-110, Doctrine\Query
now has getQueryBuilder()