【发布时间】:2015-04-11 15:40:54
【问题描述】:
在这种情况下如何转换数组数据以使用它?特别是在wordpress中。 当我打印结果时,我得到了 stdClass 对象。
Array
(
[0] => stdClass Object
(
[posts_id] => 336
[value] => 8
[count(*)] => 2
)
[1] => stdClass Object
(
[posts_id] => 329
[value] => 2
[count(*)] => 1
)
[2] => stdClass Object
(
[posts_id] => 327
[value] => 3
[count(*)] => 1
)
[3] => stdClass Object
(
[posts_id] => 338
[value] => 1
[count(*)] => 1
)
)
这是我的查询
<?php global $wpdb;
$test = $wpdb->get_results('select
posts_id,
value,
count(*)
From
wp_mrp_rating_item_entry_value
group by
posts_id,
value
order by
count(*) desc');
echo '<pre>';
print_r($test);
echo '</pre>';
如何从这个数组中获取数据以保存到另一个数据库表中?或者我怎样才能至少将单个值保存到每个 id 的变量中?我尝试分配但我还不知道所以我希望有人比我更了解它?感谢您的帮助。
【问题讨论】:
-
你的意思是把数据保存到其他表吗?
INSERT也许? -
@Raptor 哦,是的,请保存。我的折叠。有什么想法吗?
标签: php mysql arrays wordpress