I’ve created my first model in CodeIgniter 4 (with Shield).
I am wondering about the many additional fields I received from the following model-function.
Here is the simple function from this model:
public function users_get_by_id(int $id, array $fields=array())
{
if(empty($fields)){
return $this->find($id);
}
else
{
return $this->select($fields)->where('id', $id);
}
}
Inside the controller I get and print out the returned values like this
$data = $this->UsersModel->users_get_by_id(user_id(),['username','department_main']);
echo"<pre>";
print_r($data);
Now I am wondering why in my $data
are not only the values from the tables/fields called by the “users_get_by_id” function.
In CI3 I only recieved a array with the table fields and values.
Now there is a lot more information.
Example: print_r($data);
gives this:
AppModelsUsersModel Object([pager] =>
[db:protected] => CodeIgniterDatabaseMySQLiConnection Object
([DSN:protected] =>
[port:protected] => 3306
[hostname:protected] => ....
[username:protected] => ...
[password:protected] => ...
[database:protected] =>....
[DBDriver] => MySQLi
...many more values follow...
)
- Where are they from?
- Is it normal in CI4?
- How can I reduce the returned value only to the values from the function?
By the way what does it mean by the prepended parts like [db:protected]
etc?
Looking in the CodeIgniter docs brings no info about it.