使用不同的格式访问数组

I' am not really sure, What do we call this in PHP, let me try my best in explaining it well. I saw this type in most CMS like WordPress and Joomla.

This is the Class that fetches the row and compiles into array

public function ROWS()
{
    $rows = array();
    for ($x = 0; $x < $this->num_rows(); $x++) {
        $rows[] = mysqli_fetch_assoc($this->results);
    }
    return $rows;
}

Currently, when I want to access the array values from the query, I have to do something like this

$rows = $db->ROWS();

foreach ($rows as $module) {
    $module_name = $module["module_name"];
    $module_description = $module["module_description"];
    $module_parent = $module["module_parent"];
    $module_show_in_menu = $module["module_show_in_menu"];
    $module_order = $module["module_order"];
    $module_role = $module["module_role"];
}

My Question is how can I access the values from the database in this format Example

foreach($rows as $module){
   $module_name = $module->module_name;
   $module_description = $module->module_description;
   $module_parent = $module->module_parent;
   $module_show_in_menu = $module->module_show_in_menu;
   $module_order = $module->module_order;
   $module_role = $module->module_role;
}

To fetch objects from database, you can use the following:

$rows[] = mysqli_fetch_object($this->results);

You also could specify some class for setting properties. If not specified, objects are instances of STDClass.

Another way is casting arrays to objects:

$rows[] = (object) mysqli_fetch_assoc($this->results);

You have to convert your array to object.

$object = (object)$array;

For your case:

$module = (object)$module;