我不确定这是否有效。我试图使用concat的结果作为普通的PHP代码。但我得到纯文本结果。这是我的代码:
查询1:
T obj;
boost::function<void (const sensor_msgs::PointCloud2&)> callback =
[obj] (const sensor_msgs::PointCloud2& msg) {
// Do something here
}
auto sub = ros_nh.subscribe<sensor_msgs::PointCloud>(topic, 1, callback);
查询2:
$resultdc = $wpdb->get_row($wpdb->prepare("SELECT user_id, goals_date, YEAR(goals_date) AS yearof, DATE_SUB(DATE(goals_date), INTERVAL DAYOFWEEK(goals_date) -1 DAY) AS weekof, TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(end_time))-SUM(TIME_TO_SEC(start_time))), '%H:%i') AS st_time, SUM(TIME_TO_SEC(end_time)-TIME_TO_SEC(start_time)) AS ltime, $sumleads $sumgoals FROM $table WHERE user_id IN($members) AND DATE_SUB(DATE(goals_date), INTERVAL DAYOFWEEK(goals_date) -1 DAY) = DATE_SUB(DATE('$goals_date'), INTERVAL DAYOFWEEK('$goals_date') -1 DAY) GROUP BY weekof"));
结果:
$dcharts = $wpdb->get_row($wpdb->prepare("SELECT GROUP_CONCAT('[\"',goalname,' - \'.\$resultdc->LT',goal_id,'.\'\", \'.\$resultdc->LT',goal_id,'.\']') AS dchart FROM wpgetyp_ppi_goalsettings WHERE user_id = '$head' AND goaltype ='leadtype' GROUP BY user_id"));
我想从第一次查询中显示 $ resultdc-&gt; * 的结果。或者更好的主意。非常感谢你。
答案 0 :(得分:0)
结果中有美元符号这一事实意味着您的报价不正确。尝试使用:
"SELECT GROUP_CONCAT(
'[',
goalname,
' - {$resultdc->LT}',
goal_id,
'{$resultdc->LT}',
goal_id,']') AS dchart
FROM wpgetyp_ppi_goalsettings
WHERE user_id = '{$head}'
AND goaltype ='leadtype'
GROUP BY user_id"
as sql-statement