我有 2 个类别“cele_birth”和“cele_anniv”。我想在 drupal 7 中的单个查询中获取这两个值。我尝试如下。我只返回 cele_anniv 结果。如何获取这两个值
$result = db_query('select response from {soap_service} where category = :category',array(':category' => 'cele_birth',':category' => 'cele_anniv'));
foreach($result as $record){
$data = $record->response;
$data = drupal_json_decode($data);
print_r($data);
}
最佳答案
sql中必须使用OR条件
$result = db_query('select response from {soap_service} where category = :category1 OR category = :category2',array(':category1' => 'cele_birth',':category2' => 'cele_anniv'));
关于php - 获取单个数组中的两个类别值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45837569/