[eluser]m4rw3r[/eluser]
This:
Code:
class Type{
function Type($data = array()){
foreach($data as $key => $val){
$this->$key = $val;
}
}
}
$query = $this->db->get_where('types',array('id' => $typeId));
$row = $query->row_array();
$type = new Type($row);
is actually marginally faster than this:
Code:
class Type{
}
$query = $this->db->get_where('types',array('id' => $typeId));
$type = mysql_fetch_object($query->result_id,'Type'));
The lower one requires MySQL and PHP 5 or higher, so I think you should use the first one.
About the includes: There is no "CI way" of including associated classes, not yet at least.
But do what you feel is right, include, require (or the *_once), $this->load->library(...) or whatever.
I recommend using the APPPATH constant (yes three P

, it is the path to your application folder) in your includes/requires, like this:
Code:
require_once APPPATH.'/myclassdir/type.php';