PHP non-object return result

$query = new BackendlessDataQuery();

$query->setWhereClause("Device.Device_ID = '84847763-E3AA-42EB-9E33-EAF7D3D0EFC7' AND Offer.bundleId = 'ID' AND isWin=false");

$array = Backendless::$Persistence->of(‘Trials’)->find($query)->getAsClass();
if (!(count($array) > 0)) {
echo “No Data”;
}
$try=new Trials();
$try=$array[0];
echo ($try->getObjectID());
And return error Fatal error: Call to a member function getObjectID() on a non-object in line 30

BTW the query work fine I try to print the $try it worked but I can’t access object.
help Please

You’re calling getObjectID() on “$Try”, while the variable is “$try”.

Also, I think it should be a property of the object (not a method):

$try->objectId

$deviceUDID=$_POST[“udid”];
$bundleId=$_POST[“bundleId”];

$query = new BackendlessDataQuery(); 
$query->setWhereClause("Device.Device_ID = '84847763-E3AA-42EB-9E33-EAF7D3D0EFC7' AND Offer.bundleId = 'ID' AND isWin=false"); 


$array = Backendless::$Persistence->of('Trials')->find($query)->getAsClass(); 
if (!(count($array) > 0)) { 
echo "No bearer_token found"; 
}	 
$try=new Trials(); 
$try=$array[0]; 

print_r (($try->objectId));

same problem I was just write it wrong in the topic

when I try to print the $try it print like a dictionary

When you print $try, what does that dictionary look like?

It Look like this

Array
(
[Achieved_Date] => 1459274561000
[Offer] => Array
(
[Offer_Description] => sdfghjk
[Offer_ExDate] =>
[bundleId] => ID
[Device_Applied_Number] => 0
[Required_Min] => 2
[Max_Apply_Number] => 100
[ownerId] =>
[__meta] => {“relationRemovalIds”:{},“selectedProperties”:[“Offer_Description”,“created”,“Offer_ExDate”,“bundleId”,“Device_Applied_Number”,“Required_Min”,“Max_Apply_Number”,“ownerId”,“Offer_Title”,“Offer_Cards”,“Offer_Image”,“Offer_Provider”,“Offer_Keys”,“Available_Country”,“appId”,“Questions”,“Offer_Type”,“Offer_Points”,“updated”,“objectId”],“relatedObjects”:{“Offer_Provider”:[“A773759F-E556-9D5E-FF70-CD92B8212100”],“Questions”:[“E5023FD9-6734-DFBA-FFC4-6EE1A83F9900”,“FC3776E5-E2D7-14A1-FFB9-48647B406B00”]}}
[Offer_Title] =>fghjkl
[Offer_Cards] => Array
(
)

        [Offer_Image] => http://www.almrsal.com/wp-content/themes/Broadcast/thumb.php?src=http://www.almrsal.com/wp-content/uploads/2014/04/Hanging-Gardens-640x198.jpg&w=650&h=200&zc=1&q=100
        [Offer_Provider] => Array
            (
                [created] => 1459204477000
                [___class] => Providers
                [ownerId] => 
                [Provider_Name] =>hjkl
                [updated] => 1459274562000
                [objectId] => A773759F-E556-9D5E-FF70-CD92B8212100
                [__meta] => {"relationRemovalIds":{},"selectedProperties":["created","ownerId","Provider_Name","updated","objectId"],"relatedObjects":{}}
            )


        [Offer_Keys] => 1
        [Available_Country] => All
        [appId] => 
        [___class] => Offers
        [Questions] => Array
            (
                [0] => Array
                    (
                        [created] => 1458717169000
                        [___class] => Questions
                        [Question] => dfghjkl;rray
                                    (
                                        [created] => 1458814525000
                                        [___class] => Quistion_Choices
                                        [choice_text] => qwertyuiop[]
                                        [ownerId] => 
                                        [__subID] => 70B481DD-D039-797D-FFE0-6D6158167200
                                        [updated] => 1459277906000
                                        [objectId] => 069062BA-F638-BB2E-FF4F-21A1360F2600
                                        [isCorrect] => 
                                        [__meta] => {"relationRemovalIds":{},"selectedProperties":["__updated__meta","created","___class","choice_text","ownerId","updated","objectId","isCorrect"],"relatedObjects":{}}
                                    )


                                [1] => Array
                                    (
                                        [created] => 1458814525000
                                        [___class] => Quistion_Choices
                                        [choice_text] => sdfghjkl;

elationRemovalIds":{},“selectedProperties”:["__updated__meta",“created”,"___class",“choice_text”,“ownerId”,“updated”,“objectId”,“isCorrect”],“relatedObjects”:{}}
)

                                [2] => Array
                                    (
                                        [created] => 1458814526000
                                        [___class] => Quistion_Choices
                                        [choice_text] => asdfghjkl
                                        [ownerId] => 
                                        [__subID] => A114739B-869E-207D-FF0F-C18AF95B4500
                                        [updated] => 1459277906000
                                        [objectId] => 8AE1D19B-4EB5-A37A-FF4A-267956CFD400
                                        [isCorrect] => 
                                        [__meta] => {"relationRemovalIds":{},"selectedProperties":["__updated__meta","created","___class","choice_text","ownerId","updated","objectId","isCorrect"],"relatedObjects":{}}
                                    )


                                [3] => Array
                                    (
                                        [created] => 1458814524000
                                        [___class] => Quistion_Choices
                                        [choice_text] => sdfghjkl
                                        [__subID] => 8047E800-5B53-D2B1-FF17-5F85076FAB00
                                        [updated] => 1459277906000
                                        [objectId] => CCB63306-4F25-9163-FF19-DB837ED1EF00
                                        [isCorrect] => 
                                        [__meta] => {"relationRemovalIds":{},"selectedProperties":["__updated__meta","created","___class","choice_text","ownerId","updated","objectId","isCorrect"],"relatedObjects":{}}
                                    )


                            )


                        [updated] => 1459277906000
                        [objectId] => E5023FD9-6734-DFBA-FFC4-6EE1A83F9900
                        [__meta] => {"relationRemovalIds":{},"selectedProperties":["created","Question","ownerId","choices","updated","objectId"],"relatedObjects":{"choices":["069062BA-F638-BB2E-FF4F-21A1360F2600","67AE1501-7448-41BB-FFDB-3D1E4CB6A900","8AE1D19B-4EB5-A37A-FF4A-267956CFD400","CCB63306-4F25-9163-FF19-DB837ED1EF00"]}}
                    )

I can access the data like this print_r ($try[“objectId”]); its worked but it’s not a solution

why is it not a solution?

because I will update the try object then save I need it to be object , do you have any examples in php I can’t find any ?

Are you saying you want the $try variable to be an instance of the Trials class? If so, can you paste here the Trials class code?

<?php namespace Ajeeb; use backendless\Backendless; use backendless\BackendlessUser; use backendless\model\GeoPoint; use backendless\model\GeoCategory; class Trials { private $objectId; private $isWin; private $Offer; private $ownerId; private $updated; private $created; private $Achieved_Date; private $Device; private $unlockKeys; private $points; public function __construct() { } public function getObjectId() { return $this->objectId; } public function getIsWin() { return $this->isWin; } public function getOffer() { return $this->Offer; } public function getOwnerId() { return $this->ownerId; } public function getUpdated() { return $this->updated; } public function getCreated() { return $this->created; } public function getAchieved_Date() { return $this->Achieved_Date; } public function getDevice() { return $this->Device; } public function getUnlockKeys() { return $this->unlockKeys; } public function getPoints() { return $this->points; } public function setObjectId( $objectId ) { $this->objectId = $objectId; } public function setIsWin( $isWin ) { $this->isWin = $isWin; } public function setOffer( $Offer ) { $this->Offer = $Offer; } public function setOwnerId( $ownerId ) { $this->ownerId = $ownerId; } public function setUpdated( $updated ) { $this->updated = $updated; } public function setCreated( $created ) { $this->created = $created; } public function setAchieved_Date( $Achieved_Date ) { $this->Achieved_Date = $Achieved_Date; } public function setDevice( $Device ) { $this->Device = $Device; } public function setUnlockKeys( $unlockKeys ) { $this->unlockKeys = $unlockKeys; } public function setPoints( $points ) { $this->points = $points; } public function save() { return Backendless::$Data->of( 'Trials' )->save( $this ); } public function remove() { return Backendless::$Data->of( 'Trials' )->remove( $this ); } public static function findById( $id, $relation_depth = null ) { return Backendless::$Data->of( 'Trials' )->findById( $id, $relation_depth ); } public static function findFirst( $relation_depth = null ) { return Backendless::$Data->of( 'Trials' )->findFirst( $relation_depth ); } public static function findLast( $relation_depth = null ) { return Backendless::$Data->of( 'Trials' )->findLast( $relation_depth ); } }

Hey Mark, having the same issue here, for example, how do I make that $try to be an instant of Trial class? Just like the guy above me, I’m also receiving an object as an Array, rather than an instantiated object which I can play around with methods.