0

Goal: Get values which are unique in $resultSecond

So I have two objects.

$result->>entity_id

$resultSecond>entity_id

I want to get values which are unique to $resultSecond and are NOT in the $result.

I tried to use array_diff(). It did not work as they are objects. I think.

Below is the code by which I am getting the data.

$result = db_query("
SELECT entity_id FROM field_data_field_date
WHERE bundle='postit' AND field_date_value > ".$customvishaltime." ");

$resultSecond = db_query("
SELECT entity_id FROM field_data_field_days
WHERE bundle='postit' AND field_days_value > ".$customvishaltime." ");

As per drupal the return of db_query is a prepared statement object. I have no clue what this means.

Reference:

For db_query http://api.drupal.org/api/drupal/includes--database--database.inc/function/db_query/7

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by vishalkhialani
0
$resultSecond = db_query("
  SELECT entity_id 
  FROM field_data_field_days
  WHERE bundle = 'postit' 
  AND field_days_value > $customvishaltime
  AND entity_id NOT IN (
    SELECT entity_id 
    FROM field_data_field_date
    WHERE bundle = 'postit' 
    AND field_date_value > $customvishaltime)
");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.