简体   繁体   English

原则,领域大于价值

[英]Doctrine, field greater than value

I am current using Doctrine's createQuery (in Symfony). 我当前正在使用Doctrine的createQuery(在Symfony中)。

For example, I have a query like this: 例如,我有这样的查询:

$dql = "SELECT * FROM table";

I am trying to add conditions to the above query. 我正在尝试为上述查询添加条件。 It seems that if you want to add a where condition, all you need to do is: 似乎,如果您想添加一个where条件,您所需要做的就是:

$query -> setParameter('new_field','new_value');

However there seem to be no solution to add a condition like this: 但是,似乎没有办法添加这样的条件:

field > 5

Is there a build in solution to this? 是否有内置解决方案? Or am I missing something? 还是我错过了什么? Workaround? 解决方法?

I am not using createQueryBuilder. 我没有使用createQueryBuilder。

Parameters are only "variables" in your query, so for example here is what you can do : 参数只是查询中的“变量”,因此例如,您可以执行以下操作:

$dql = "SELECT * FROM table WHERE myField > :myField";
$dql->setParameter( "myField", $field );

Is that what you where looking for ? 那是您要找的东西吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM