Wie kann ich auf den Wert overall_score zugreifen, ohne eine foreach jede Schleife zu tun?Wie greife ich auf diese Objekteigenschaft ohne foreach-Schleife zu
Ich versuche, den Wert Gesamtnote erhalten, habe ich versucht $links->overall_score
aber ich bekomme:
Notice: Undefined property: mysqli_native_moodle_recordset::$overall_score in /Users/richard/Sites/moodle/moodle/report/link_critic/link_detail.php on line 90
So bin ich
tun$links = $DB->get_recordset_sql($query_links);
hier ist das Objekt, das ich zurück von meiner Anfrage erhalten
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
)
)
A Var Dump von $ Links-> current()
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" }
Eine Vermutung nach einer schnellen Google-Suche, $ links-> current() ['overall_score'] '? (Abhängig von der PHP-Version). –
Es sieht so aus, als hätte es ein paar Arrays. Probieren Sie $ links-> current ["overall_score"] ' –
@JeffPuckettII $ links ist ein Objekt nach dem Aussehen, und die' current' Eigenschaft ist geschützt. –