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

Have you tried the SELECT DISTINCT and possibly WHERE NOT EXISTS clauses?

$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)
");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.