我在WordPress中运行以下SQL查询。
$mylink = $wpdb->get_results("SELECT `object_id` FROM `wp_term_relationships` WHERE `term_taxonomy_id` = (SELECT `term_id` FROM `wp_terms` WHERE `slug` LIKE 'jabong')");
显示值来自数组。
foreach($mylink as $key => $row) {
echo $row->object_id."<br>";
}
我得到了以下输出。 109957109834109952109964109670
我想将此值存储为String 109957,109834,109952,109964,109670。 所以请帮助我如何将这个值存储在字符串中。
答案 0 :(得分:0)
$string = "";foreach($mylink as $key => $row) { $sting.=$row->object_id.",
"; }
$string = substr($string,0,-1);