stdclass

Get value from STDClass

一笑奈何 提交于 2021-02-08 12:01:40
问题 I'm using PHP and CodeIgniter. I ran a query using the following script: $query = $this->db->query('select login_id, date_created from prjsite_login'); $row = $query->result(); print_r($row); The result of the print_r is: Array ( [0] => stdClass Object ( [login_id] => admin [date_created] => 2018-04-04 13:18:42 ) ) Which is correct. Thou when I tried to fetch 1 object or value from stdClass using the following script: echo $query->login_id; I received an error below: A PHP Error was

PHP SoapClient call response missing parts of answer

强颜欢笑 提交于 2021-02-07 08:28:33
问题 I am having trouble with PHP parsing of a SoapClient call's response. For some types of answers, it is returning arrays of empty stdClass objects instead of initialized stdClass objects. The server is a java webservice deployed with axis2 on tomcat6. The Java signature of the problematic service call is public Course getCourseDetails(Long courseId) Course is a standard POJO defined as: public class Course { private Long id; private List<Hole> holes; private String name; private String tees; /

PHP SoapClient call response missing parts of answer

青春壹個敷衍的年華 提交于 2021-02-07 08:24:04
问题 I am having trouble with PHP parsing of a SoapClient call's response. For some types of answers, it is returning arrays of empty stdClass objects instead of initialized stdClass objects. The server is a java webservice deployed with axis2 on tomcat6. The Java signature of the problematic service call is public Course getCourseDetails(Long courseId) Course is a standard POJO defined as: public class Course { private Long id; private List<Hole> holes; private String name; private String tees; /

PDO Statement does not work anymore in PHP 7

时光怂恿深爱的人放手 提交于 2021-01-29 22:24:15
问题 When I switch from PHP 5.6 to 7.0 or 7.2., this statement does not work anymore: $translator = new stdClass(); $sql = "SELECT name, value FROM ".$tab_translator." WHERE lang_id=:lang_id"; try { $fetchTextTranslated = $conn->prepare($sql); $fetchTextTranslated->bindValue(':lang_id', (int) trim($translator_lang_id), PDO::PARAM_INT); $fetchTextTranslated->execute(); } catch(PDOException $e) { if ($config->debug==1) { echo 'Error: ' . $e->getMessage(); }} while ($textTranslated =

PDO Statement does not work anymore in PHP 7

南笙酒味 提交于 2021-01-29 21:51:42
问题 When I switch from PHP 5.6 to 7.0 or 7.2., this statement does not work anymore: $translator = new stdClass(); $sql = "SELECT name, value FROM ".$tab_translator." WHERE lang_id=:lang_id"; try { $fetchTextTranslated = $conn->prepare($sql); $fetchTextTranslated->bindValue(':lang_id', (int) trim($translator_lang_id), PDO::PARAM_INT); $fetchTextTranslated->execute(); } catch(PDOException $e) { if ($config->debug==1) { echo 'Error: ' . $e->getMessage(); }} while ($textTranslated =

When should I use stdClass and when should I use an array in php oo code?

大兔子大兔子 提交于 2020-01-26 15:12:07
问题 In the middle of a period of big refactorings at work, I wish to introduce stdClass ***** as a way to return data from functions and I'm trying to find non-subjectives arguments to support my decision. Are there any situations when would it be best to use one instead of the other ?? What benefits would I get to use stdClass instead of arrays ?? Some would say that functions have to be as little and specific to be able to return one single value. My decision to use stdClass is temporal, as I

Trying to print properties of stdClass object in Php starting with literal '$'

邮差的信 提交于 2020-01-21 09:55:47
问题 My object name is $distinct1 print_r($distinct1) shows the object below but when I try to do echo $distinct1->properties->city OR echo $distinct1->distinct_id I don't get any value return. Any idea whats going on? stdClass Object ( [$distinct_id] => AAA [$properties] => stdClass Object ( [$city] => Palo Alto [$country_code] => US [$region] => California [$name] => John Smith ) ) 回答1: Hm, if your properties are really named like that: $distinct1->{'$properties'}->{'$city'} But if possible, I'd

Trying to print properties of stdClass object in Php starting with literal '$'

ⅰ亾dé卋堺 提交于 2020-01-21 09:52:14
问题 My object name is $distinct1 print_r($distinct1) shows the object below but when I try to do echo $distinct1->properties->city OR echo $distinct1->distinct_id I don't get any value return. Any idea whats going on? stdClass Object ( [$distinct_id] => AAA [$properties] => stdClass Object ( [$city] => Palo Alto [$country_code] => US [$region] => California [$name] => John Smith ) ) 回答1: Hm, if your properties are really named like that: $distinct1->{'$properties'}->{'$city'} But if possible, I'd

PHP, stdClass, select elements contains specifed element

妖精的绣舞 提交于 2020-01-07 06:50:14
问题 I have an stClass object like this: object(stdClass)#2 (6) { [0]=> object(stdClass)#44 (2) { ["uid"]=> int(3232) ["type"]=> string(7) "sibling" } [1]=> object(stdClass)#43 (2) { ["uid"]=> int(32323) ["type"]=> string(7) "sibling" } [2]=> object(stdClass)#42 (2) { ["uid"]=> int(3213) ["type"]=> string(10) "grandchild" } [3]=> object(stdClass)#41 (3) { ["uid"]=> int(-680411188) ["type"]=> string(6) "parent" } [4]=> object(stdClass)#40 (3) { ["uid"]=> int(-580189276) ["type"]=> string(6) "parent

Printing an stdClass object

时光怂恿深爱的人放手 提交于 2020-01-06 03:40:30
问题 I have: $value = $wpdb->get_row("SELECT custom_message FROM `wp_wpsc_cart_contents` WHERE purchaseid='" . $purchase_log['id'] . "'"); if I do: print_r($value); I get: stdClass Object ( [custom_message] => |Castor Seed Oil $4.45| ) So I tried to get that value doing: foreach($value as $index => $result) { echo $result["custom_message"]; } I also tried: foreach($value as $index => $result) { echo $result->custom_message; } but that prints nothing, any idea what I'm doing wrong here? 回答1: The