如何在不对每个循环执行foreach的情况下访问overall_score值?如何在没有foreach循环的情况下访问此对象属性
我试图获取的价值总体得分,我想$links->overall_score
但我得到:
Notice: Undefined property: mysqli_native_moodle_recordset::$overall_score in /Users/richard/Sites/moodle/moodle/report/link_critic/link_detail.php on line 90
所以我做
$links = $DB->get_recordset_sql($query_links);
这里的对象,我从我的查询
找回 的$链接 - >电流()mysqli_native_moodle_recordset Object
(
[result:protected] => mysqli_result Object
(
[current_field] => 0
[field_count] => 17
[lengths] => Array
(
[0] => 4
[1] => 4
[2] => 2
[3] => 1
[4] => 10
[5] => 24
[6] => 18
[7] => 1
[8] => 0
[9] => 29
[10] => 5
[11] => 4
[12] => 1
[13] => 1
[14] => 0
[15] => 10
[16] => 1
)
[num_rows] => 21
[type] => 0
)
[current:protected] => Array
(
[id] => 17397
[resource_id] => 2512
[page_id] => 15
[user_id] => 1
[link_submitted] => 1462649904
[link_title] => Cold Spring Harbour page
[link_description] => A useful brain map
[link_status] => 1
[link_broken] =>
[link_url] => http://www.g2conline.org/2022
[link_id] => 1583
[vote_score] => 1
[vote_comment] =>
[vote_timestamp] => 1464795526
[overall_score] => 1
)
)
一个VAR转储
object(stdClass)#4476 (15) { ["id"]=> string(5) "17397" ["resource_id"]=> string(4) "2512" ["page_id"]=> string(2) "15" ["user_id"]=> string(1) "1" ["link_submitted"]=> string(10) "1462649904" ["link_title"]=> string(24) "Cold Spring Harbour page" ["link_description"]=> string(18) "A useful brain map" ["link_status"]=> string(1) "1" ["link_broken"]=> NULL ["link_url"]=> string(29) "http://www.g2conline.org/2022" ["link_id"]=> string(4) "1583" ["vote_score"]=> string(1) "1" ["vote_comment"]=> NULL ["vote_timestamp"]=> string(10) "1464795526" ["overall_score"]=> string(1) "1" }
快速谷歌搜索后的猜测,'$ links-> current()['overall_score']'? (取决于PHP版本)。 –
它看起来像是有几个数组。尝试'$ links-> current [“overall_score”]' –
@JeffPuckettII $ links是它的外观的一个对象,'current'属性受到保护。 –