在drupal 7中调用未定义的方法stdClass::count()
我对Drupal7中的计数函数有一个问题 代码是:在drupal 7中调用未定义的方法stdClass::count(),drupal,drupal-7,Drupal,Drupal 7,我对Drupal7中的计数函数有一个问题 代码是: $sql = "select count(Status) from TB_Aanmeldingen where (Status= 'Ja' or Status='Ja, met kleine') and ID_Wedstrijd = :match"; $args = array(':match' => $match); $row = db_query($sql, $args)->fetchObject();
$sql = "select count(Status) from TB_Aanmeldingen where (Status= 'Ja' or Status='Ja, met kleine') and ID_Wedstrijd = :match";
$args = array(':match' => $match);
$row = db_query($sql, $args)->fetchObject();
$aantal = $row->count(Status);
错误消息:
Call to undefined method stdClass::count()
非常感谢您的帮助 我不确定你想用它做什么:
$aantal = $row->count(Status);
对$row对象执行print\r或var\u转储,您将看到结构是什么。db_查询返回一个DatabaseStatementInterface,您将从中获取一个对象。但是对象没有您试图调用的函数
相反,调试、打印和调试$row的值,并获取您要查找的值
另外,查看db_select。最好使用该查询,然后使用db_查询