By Anonymous (not verified) on
Hi all
I'm writing a custom module for an autocomplete field and I'm trying to extract all term ids related to a given parent id ($pid):
Currently, I'm using this code which is doing very well:
$query = db_select('taxonomy_term_hierarchy', 'p')
->fields('p', array('tid'))
->condition('p.parent', $pid)
->execute()
->fetchAllKeyed();
$query = array_keys($query);
...and $pid is an array containing a valid term id.
Unfortunately, whenever the autocomplete field makes a callback, it creates the same error several times:
Notice: Undefined offset: 1 in DatabaseStatementBase->fetchAllKeyed() (line 2177 of /home/drupal_root/includes/database/database.inc).
Any guess what's causing this?
Thanks
Propa
Comments
bump :)
bump :)
Got it.->fetchAllKeyed
Got it.
->fetchAllKeyedshould be->fetchColand then the next line isn't necessary anymore.