Is there a way to use SQL functions with the EntityFieldQuery class?

What I am trying to do is something similar to the following code:

$query_user = new EntityFieldQuery;


The interesting part is the EntityFieldQuery::fieldCondition() call. Obviously this it isn't working, otherwise I would not ask this question.

2 Answers 2


No. The whole point of EntityFieldQuery is that it is SQL-agnostic, so you can switch from MySQL to MongoDB for example, and it still works.


The first parameter to fieldCondition is expecting to be the field you want to query. So unless you have a field called MD5(user+pass) this won't work. You can't query with arbitrary SQL like that.

Read the documentation linked above about how to use the method. This is generally a good place to start when things don't work, to check if you can do what you are trying to do.

From the doc:

public EntityFieldQuery::fieldCondition($field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL)

$field Either a field name or a field array.

  • Stackexchange says to offer a comment with a downvote so here goes: The question is "Is there a way to use SQL functions with the EntityFieldQuery class?", not "how does fieldCondition work?" The poster only wrote code as a model of what s/he would like to do with a similar function. So this response does not answer the question.
    – user1359
    Aug 2, 2013 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.