mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
and, or doesn't work in DQL #5950
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @winnilein on GitHub (Apr 12, 2018).
I migrate a mysql db to sqlAnywhere(sqla) to test my app developed with Doctrine2.
Acces to sqla works,
DQL like
$query = $em->createQuery('SELECT e FROM countries e WHERE e.conlng = :lng );
$query->setParameters(array(
'lng' => 'DE'
));
$result = $query->getResult();
also runs funny.
$query = $em->createQuery('SELECT e FROM countries e WHERE e.connum = :num );
$query->setParameters(array(
'num' => '4'
));
$result = $query->getResult();
also no problems!
BUT!
$query = $em->createQuery('SELECT e FROM countries e WHERE e.conlng = :lng AND e.connum = :num');
$query->setParameters(array(
'lng' => 'DE',
'num' => '4',
));
$result = $query->getResult();
doesn't work!!
$result = empty!
with operator OR it's the same problem!
Any idea!
@Ocramius commented on GitHub (Apr 12, 2018):
What's the executed SQL query? Can you run that manually and verify the output? Also make sure the parameter types match.
@winnilein commented on GitHub (Apr 13, 2018):
Interactive sql works!
But if i change my test-pgm to this ..
look at the sql statement!
SELECT e FROM countries e WHERE e.conlng = :lng or e.connum = :num
and the result in the sceenshot.
It woorks with an OR operator??!
I'm very irritated !
@Ocramius commented on GitHub (Apr 13, 2018):
Is this the same SQL statement that the ORM runs?
Use a
DebugStacklogger to see if the SQL statement is the same.The one difference I noticed is that sometimes your parameters are
string, sometimesint: try looking for differences there as well as in the executed SQL string.This is not a support hotline: if you need to get irritated over volunteers helping you out, you can instead hire somebody to help you out, and be (contractually) allowed to be irritated instead.
@winnilein commented on GitHub (Apr 13, 2018):
The result ofDebugStack!?
@Ocramius commented on GitHub (Apr 13, 2018):
@winnilein can you expand on
paramsandtypesthere?@winnilein commented on GitHub (Apr 13, 2018):
@Ocramius commented on GitHub (Apr 13, 2018):
Both are bound as
stringthere - can you try passing in an integer and running the SQL statement manually with eitherstringorint, and see if there is a difference?@winnilein commented on GitHub (Apr 13, 2018):
native sql..

and the result of my script..
my script..
@winnilein commented on GitHub (Apr 13, 2018):
For your entertainment..
$query = $em->createQuery('SELECT e FROM countries e WHERE e.conlng = :lng AND e.connum = :num');$NUM = 4;result ->
and now !
$query = $em->createQuery('SELECT e FROM countries e WHERE e.conlng = :lng or e.connum = :num');$NUM = '4';result..
f****** web apps
i think i continue programming midrange applications
@Ocramius commented on GitHub (Apr 13, 2018):
Closing: nobody's spare time is worth following up on this attitude.
If you don't have the willpower to contribute to this conversation in a constructive way, then please consider hiring somebody doing it for you instead.