K
K
kid552015-11-23 13:20:45
PHP
kid55, 2015-11-23 13:20:45

How to make a selection with a condition in Drupal 7?

I'm making a selection of users from the database, I want to set a condition: depending on the selected value in the field I added with a checkbox for the user, display only users in which field value [1]
Now I just display all users, except for those who have the "Blocked" status

$q = db_select('users', 'u');
  $q->fields('u', array('uid'))
    ->condition('status', 0, '!=');
  $r =  $q->execute()->fetchAll();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tlito, 2015-11-23
@tlito

->condition('field', 'value','=');

A
andead, 2015-11-23
@andead

add leftJoin of table with field data
add condition

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question