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.
    – rooby
    Commented Mar 14, 2018 at 13:13
  • Yeah right @rooby, I added note in answer.
    – vijay
    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!
    – Sam
    Commented Mar 14, 2018 at 18:21
  • something like array_column($tids, 'tid') perhaps ^
    – Johan
    Commented Nov 21, 2019 at 12:04

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.