Undefined property: stdClass::$userNAME and Undefined index: userNAME |
I am pulling information from a database that arrive with one field named userNAME. I am using $query->getResultObject()[see https://codeigniter4.github.io/userguide...ult-arrays] therefore giving me an array of objects. The data in this field is a ';' separated list which I am processing into an array and storing back in the field of the object holding an element of the result array.
In the end what I have is $Object->userNAME as an array with a number of keys, one of them 'full'; So to access a full name, I use $Object->userNAME['full']; This has been working for me for years in CI3. I am moving to CI4 and the trouble is that now in CI4 I get the error Undefined property: stdClass::$userNAME when I issue $Object->userNAME['full']; I assumed the problem was Object so I converted all operations to Array, thus accessing full name now becomes $Object['userNAME']['full']; only to meet the error Undefined index: userNAME Some two strange observations to me 1. When I issue echo $Object['userNAME']['full']; or echo $Object->userNAME['full']; I get the error Undefined index: userNAME and Undefined property: stdClass::$userNAME respectively but still get the expected output! 2. With the array usage, I get the output 1 and the full name but with the warning when I issue the following! echo array_key_exists ('userNAME' , $Object ); //output is 1 $Object['userNAME']['full']; //output is a full name and also error message I am stuck, please help. |
Messages In This Thread |
Undefined property: stdClass::$userNAME and Undefined index: userNAME - by owino - 03-23-2020, 02:33 AM
RE: Undefined property: stdClass::$userNAME and Undefined index: userNAME - by includebeer - 03-24-2020, 03:04 PM
RE: Undefined property: stdClass::$userNAME and Undefined index: userNAME - by owino - 03-25-2020, 02:00 AM
|