I'm having trouble figuring out how to use EntityQuery in custom field values. As an example, I have a custom field below the user package that stores the country in which the user lives. There are three options: United States, Canada and Mexico. I would like to use EntityQuery to directly consult the & # 39; field_country & # 39; to get a count of how many live in a country and get their uids. Here is an export of the database for this field:
The closest I've gotten is the code snippet below. However, this does not work and I'm not sure where to go from here.
$ results = Drupal :: entityQuery (& # 39; user & # 39;) -> condition (& # 39; field_country & # 39 ;, & # 39; Canada & # 39;) -> execute ();
Someone knows? Does the query entity give me the ability to see specific columns in a field? Thank you!
PS I know I could do this with a database query, but I would prefer to do it in the Drupal way.