[eluser]m4rw3r[/eluser]
Answers:
1:
Well, the autoloading is currently not implemented (I think that it is a bit too much work, because all coders may want to autoload in a different way (or sort or whatever)), but you can easily do it yourself, there are three options:
* Create a wrapper method in a derived class which automatically calls $rec->related(whatever) and assigns it to the record
Code:
function &find;($id) // call it whatever you like
{
$rec =& parent::find($id);
$rec->users =& $rec->related('users')->get();
return $rec;
}
* Add a hook which does it for you:
Code:
function load_users(&$rec)
{
$rec->users =& $rec->related('users')->get();
}
// register:
$this->group->add_hook(array('post_get', 'post_find', 'post_find_by'), 'load_users');
* Add a hook that automatically joins them in before the query is run:
Code:
function load_users(&$model)
{
$model->join_related('users'); // the new join_related() from 1.0
}
// register:
$this->group->add_hook(array('pre_get', 'pre_find', 'pre_find_by', 'pre_find_all', 'pre_find_all_by'), 'load_users');
2:
Well, IgnitedQuery just sends them to $CI->db->query(), so it is either $Ci->db->last_query() or the profiler. (btw, last_query() is in DB_driver, not in AR)
3:
Depends on your PHP version:
PHP 4: needs to have objects passed by reference, so there you must use =& when fetching objects
PHP 5+: Always passes objects via reference, so there you can use =