1

I'm receiving the following error:

Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2227 of includes/database/database.inc).

I've narrowed it down to this code but I am still able see what is wrong with the code, it worked before but now I am getting this recurring error.

case 'field_home' : $tids = field_get_items('node', $node, $key, $node->language); $terms = taxonomy_term_load_multiple(array(), array('tid' => $tids)); // Gets Field Array Based on Term IDs $name = array(); foreach($terms as $term){ $name[] = $term->name;} $return[$key_clean] = $name; 

1 Answer 1

3

Please pass $tids array direct to the function. E.g:

$terms = taxonomy_term_load_multiple($tids); 

NOTE: Also before passing $tids to the function, please check it is include only tids. E.g:

$tids should be like $tids = [10,11,12,13,...];

4
  • In addition, the output of field_get_items() is not suitable to be passed into taxonomy_term_load_multiple() without some additional manipulation. Commented Mar 14, 2018 at 13:13
  • Yeah right @rooby, I added note in answer. Commented Mar 14, 2018 at 13:15
  • @vijay my $tids is outputting a multi value the tids are in there but ther is excess data , how could I change to output = [10,11,12,13,...]; thx! Commented Mar 14, 2018 at 18:21
  • something like array_column($tids, 'tid') perhaps ^ Commented Nov 21, 2019 at 12:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.