using php API need help extracting data from array of objects

hi guys
i have successfully connected with backendless using php and saving data fine now i want to get data from a table and then after that extract that data …
im using this code to send a hit to backendless
$catList = $ali->getListCategory();
$orders= new Orders();
$res = Backendless::$Persistence->of(“Orders”)->find( $data_query_or_relation_depth = null );

var_dump($res);
in responce im geeting result in the form of array of objects but i dont know how to extract data out of it using php loop … i have been searching on it and i dont understand what to do…
my responce code below

object(backendless\model\BackendlessCollection)#14 (2) {
["data":"backendless\model\BackendlessCollection":private]=>
array(4) {
["offset"]=>
int(0)
["data"]=>
array(10) {
[0]=>
array(23) {
["zip"]=>
string(7) "3847474"
["country"]=>
string(7) "jsshdhd"
["productId"]=>
string(11) "32529049331"
["originalPrice"]=>
string(9) " US $0.56"
["add_note"]=>
string(0) ""
["salePrice"]=>
string(9) " US $0.48"
["evaluateScore"]=>
string(1) "5"
["city"]=>
string(7) "sjdhfjd"
["created"]=>
float(1461591152000)
["lotNum"]=>
string(1) "1"
["discount"]=>
string(3) "15%"
["ownerId"]=>
NULL
["packageType"]=>
string(6) " piece"
["__meta"]=>
string(317) "{"relationRemovalIds":{},"selectedProperties":["zip","country","productId","originalPrice","add_note","salePrice","evaluateScore","city","created","lotNum","discount","ownerId","packageType","productTitle","streetAddress","imageUrl","name","___class","productUrl","category","updated","objectId"],"relatedObjects":{}}"
["productTitle"]=>
string(92) " New Micro Roller 1PCS KW1-103 Microswitch SPDT 16A AC 250V Micro Switch Lever Red And Black"
["streetAddress"]=>
string(10) "sjshdhs 23"
["imageUrl"]=>
string(147) " http://g03.a.alicdn.com/kf/HTB1qJ52KpXXXXX0XFXXq6xXFXXXr/New-Micro-Roller-1PCS-KW1-103-Microswitch-SPDT-16A-AC-250V-Micro-Switch-Lever-Red-And.jpg"
["name"]=>
string(6) "mandnd"
["___class"]=>
string(6) "Orders"
["productUrl"]=>
string(49) " http://www.aliexpress.com/item//32529049331.html"
["category"]=>
string(1) "5"
["updated"]=>
NULL
["objectId"]=>
string(36) "570EA955-0EA5-52AE-FF78-64C71FDBC300"
}
[1]=>
array(23) {
["zip"]=>
string(5) "54000"
["country"]=>
string(8) "pakistan"
["productId"]=>
string(11) "32254388130"
["originalPrice"]=>
string(9) " US $1.92"
["add_note"]=>
string(0) ""
["salePrice"]=>
string(9) " US $1.92"
["evaluateScore"]=>
string(1) "5"
["city"]=>
string(6) "lahore"
["created"]=>
float(1461588789000)
["lotNum"]=>
string(1) "1"
["discount"]=>
string(2) "0%"
["ownerId"]=>
NULL
["packageType"]=>
string(6) " piece"
["__meta"]=>
string(317) "{"relationRemovalIds":{},"selectedProperties":["zip","country","productId","originalPrice","add_note","salePrice","evaluateScore","city","created","lotNum","discount","ownerId","packageType","productTitle","streetAddress","imageUrl","name","___class","productUrl","category","updated","objectId"],"relatedObjects":{}}"
["productTitle"]=>
string(128) " 2015 Luxury Crystal Watch Unisex Bling Formal Dress Watches For Couple Business Leather Reloj Geneva Wristwatch Free Shipping"
["streetAddress"]=>
string(9) "fane road"
["imageUrl"]=>
string(168) " http://g02.a.alicdn.com/kf/HTB17rKlIFXXXXbhXXXXq6xXFXXXI/2015-Luxury-Crystal-Watch-Unisex-Bling-Formal-Dress-Watches-For-Couple-Business-Leather-Reloj-Geneva-Wrist.jpg"
["name"]=>
string(6) "salman"
["___class"]=>
string(6) "Orders"
["productUrl"]=>
string(49) " http://www.aliexpress.com/item//32254388130.html"
["category"]=>
string(4) "1511"
["updated"]=>
NULL
["objectId"]=>
string(36) "B83C01CF-8A29-F8BE-FF9B-8A97D5137200"
}

when i try to extract data using php foreach loop it gives some kind of error Private data
can anyone fast help me out on this please :(i did not found proper code on the website reated to that. or i missed something.thanks in advance

anyone?? :frowning:

Hi Muhammad,
The data is stored in the “data” field of the response.

["data"]=>
array(10)

You should be able to iterate this array like any other PHP array.

hi Sergey thanks for your reply

im trying this way

foreach($res->data as $row)
{

	echo $row->created;	

}

but it gives error : Cannot access private property backendless\model\BackendlessCollection::$data

any help here??

Because “data” property is private and you cannot access it directly.
See the source code of BackendlessCollection class: https://github.com/Backendless/PHP-SDK/blob/master/backendless/src/model/BackendlessCollection.php
It has several “getAs…” method, which you can use to retrieve the data.