Notice: Indirect modification of overloaded element of builder\Database\Collections\Collection has no effect #4
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
wontfix
This will not be worked on
When you see this Error:
Nothing wrong and it's because your trying to change the collection data value without converting to an array.
$rows = $db->table('tb_user')->where('user_id', $user_id)->get();
// You cannot direct change the collection data
// Instead you can use a new variable name
// or Convert to an array first before loop
foreach($rows as $key => $value){
$rows[$key]['address'] = json_decode($value['address'], TRUE);
}
Example 1:
$rows = $db->table('tb_user')->get()->toArray();
// Immediately you convert data to array, This will not be a collection instance anymore
// It becomes an array
foreach($rows as $key => $value){
$rows[$key]['address'] = $value['address'];
}
Example 2:
$rows = $db->table('tb_user')->get(;
$data = [];
foreach($rows as $key => $value){
$data[$key]['address'] = $value['address'];
}
The text was updated successfully, but these errors were encountered: