• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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 

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

I assumed the problem was Object so I converted all operations to Array, thus accessing full name now becomes
only to meet the error
Undefined index: userNAME

Some two strange observations to me
1. When I issue 
echo $Object['userNAME']['full'];
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.

Why don’t you just dump the whole object to see what it contains? Then you will see what’s wrong...
Test your translation files with Translation Tester

For the time being, I am making do with @$Object['userNAME']['full'] which is working.

I hope to investigate this later.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.