这是我的查询,我想将其作为
执行$query="select * from $post INNER JOIN $postmeta on $postmeta.post_id= $post.ID
where $post .post_status='publish'
and $post .post_type ='task
and $post .post_type='service'
ORDER BY $post .post_date DESC ";
如何执行
答案 0 :(得分:0)
以前对var $ postmeta和$ post的正确消毒可以这样做 通过字符串连接构建dinamic查询(因为在sql中不允许使用tabel和列名称中的var)
$query="select * from " . $post . " INNER JOIN " .
$postmeta . " on " . $postmeta . ".post_id= " . $post .".ID where " .
$post . ".post_status='publish' and " . $post .".post_type ='task' and " .
$post . "post_type='service' ORDER BY " . $post .".post_date DESC ";