这是我使用的查询:
$idList="32,33,21,11";
$query = "SELECT post_id, meta_value FROM wp_posts
WHERE meta_key = 'grade' AND post_id IN ($idList)";
结果,where 子句成为键:
$result = array(
0 => array('post_id'=> 32, 'meta_value'=>5),
1 => array('post_id'=> 33, 'meta_value'=>2),
2 => array('post_id'=> 21, 'meta_value'=>8),
)
我希望有这样的结果:
$result = array(
0 => array( 32 => 5 ),
1 => array( 33 => 2 ),
2 => array( 21 => 8 ),
)
如何做到这一点?谢谢!