• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undefined property: stdClass::$userNAME and Undefined index: userNAME

#1
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.
Reply

#2
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
Reply

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

I hope to investigate this later.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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