CodeIgniter MVC和循环通过MySQL表

I'm trying to create a iterate through a row in a MySQL table in one of my CodeIgniter projects, how could I "loop" through the table? Is it just a simple for loop like in other languages?

EDIT:

The answer is as followed:

$query = $this->db->get('mytable'); // select table "mytable" from database

foreach ($query->result() as $row) { // loop thru table and access each row's field 
                                     // by using $row->fieldname


}

Maybe something like this

//$this->db->limit(10); // Optional if you want to limit, read about it
$result = $this->db->get('server'); //return all rows

foreach ($result as $row) {
    $row->status = 'inactive'; // change value of status attribute or whatever
    $this->db->update('server', $row)
}

Or maybe use $this->db->update_batch(); to update a stack of rows at one time.

I encourage you to read the CI database class documentation too.

Another suggestion, is to do all the business logic inside a model instead of a controller. But it's a matter of personal preference maybe.