I'm using an API that results an array like this when there is data:
object(stdClass)#38 (5) {
["ReturnCode"]=>
int(1)
["EntityResults"]=>
object(stdClass)#39 (1) {
["Entity"]=>
object(stdClass)#40 (15) {
["id"]=>
int(43622)
["UserDefinedFields开发者_运维技巧"]=>
object(stdClass)#41 (0) {
}
["TicketID"]=>
int(31024)
["InternalAllocationCodeID"]=>
int(28303142)
["Date"]=>
string(19) "2011-03-24T00:00:00"
["StartDateTime"]=>
string(19) "2011-03-24T11:41:00"
["EndDateTime"]=>
string(19) "2011-03-24T11:46:00"
["HoursWorked"]=>
float(0.08)
["HoursToBill"]=>
float(0.0833333358)
["OffsetHours"]=>
float(0)
["SummaryNotes"]=>
string(584) "Hi Steve..."
["InternalNotes"]=>
string(0) ""
["RoleID"]=>
int(24482927)
...
...
...
...
Then I have some record that return the results:
object(stdClass)#33 (5) {
["ReturnCode"]=>
int(1)
["EntityResults"]=>
object(stdClass)#34 (0) {
}
["EntityResultType"]=>
string(9) "timeentry"
["Errors"]=>
object(stdClass)#35 (0) {
}
["EntityReturnInfoResults"]=>
object(stdClass)#36 (0) {
}
}
With this last result I get an error
everity: Notice
Message: Undefined property: stdClass::$Entity
Filename: models/tickets_model.php
My question is how can I avoid getting this error? I've tried
if($result->queryResult->EntityResults->Entity):
$noteso = $result->queryResult->EntityResults->Entity;
if(count($noteso)):
return $noteso;
else:
return false;
endif;
endif;
But then I get the same error but in the IF statement.
Hope there's enough here for someone to understand what's happening.
Most appreciated with any help,
Billy
If I understand correctly, this is what you want:
if(isset($result->queryResult->EntityResults->Entity)):
精彩评论