2
/**
 * Gets the nodequeue id by nodequeue name
 */
function my_module_get_nodequeue_id_by_name($name) {
  $data = db_query('SELECT qid FROM {nodequeue_queue} WHERE title = :title', array(':title' => $name))->fetchField();
  return $data->qid;
}

The above code produced this kind of notice:

Notice: Trying to get property of non-object in my_module_get_nodequeue_id_by_name() (line 30 of my_module/my_module.module).

1 Answer 1

5

fetchField() returns a single value, not an object. You either want to use fetchField() like this:

$qid = db_query('SELECT qid FROM {nodequeue_queue} WHERE title = :title', array(':title' => $name))->fetchField();
return $qid;

or use fetchObject() instead:

$data = db_query('SELECT qid FROM {nodequeue_queue} WHERE title = :title', array(':title' => $name))->fetchObject();
return $data->qid;
0

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.