【发布时间】:2014-03-09 04:09:45
【问题描述】:
我需要同时执行两条SQL语句,因为第一条语句中的connection_id()会在Mysql视图wp_statistics_benchmarks中使用。
没有connection_id(),wp_statistics_benchmarks 是一个空视图。以下 SQL 工作正常并获得结果:
replace into wp_params (`view_name` , `param1_val`, `connection_id`)
values ('benchmarks', 484 , connection_id())
;
select * from wp_statistic_benchmarks;
但是,要使用 wordpress,以下代码不起作用:
$mysqli = new mysqli(.....);
$results = $this->_wpdb->query("
replace into wp_params (`view_name`, `param1_val`, `connection_id`)
values ('benchmarks', $connected_from, $mysqli->thread_id);
select * FROM `wp_statistic_benchmarks`;"
);
如何将这两个 mysql 代码转换为 Wordpress wpdb 查询?
【问题讨论】:
-
你不能使用 mysqli->multi_query 函数吗?你真的必须使用 wpdb 吗?
-
如果this 没有解决您的问题,那么您需要向我们展示
wp_statistic_benchmarks的定义,因为您确实似乎对问题的真正含义感到困惑。