Welcome Guest, Not a member yet? Register   Sign In
IgnitedRecord 1.0 pre-release

[eluser]m4rw3r[/eluser]
PM:ed the details

[eluser]___seb[/eluser]
@m4rw3r : thanks a lot. While you're writting the doc, to me, it could be helpfull to have whole code in the Getting started section

[eluser]m4rw3r[/eluser]
What getting started section? Quick start?

[eluser]m4rw3r[/eluser]
A notice to all IgnitedRecord users out there!

I've dropped support for CodeIgniter's ActiveRecord lib as SQL builder.

The reasons are the following:
* The need to maintain both PHP 4, PHP 5 and then a variant which is becoming increasingly different
* No possibility to construct multiple queries at the same time, causing things to mess up
* No support for nested WHERE statements
* No support for subqueries
* IgnitedQuery is faster
* Problems with SELECT something.* in 1.7 (fixed in SVN, I know)
* IgnitedQuery (should be) / is completely backwards compatible (tell me if it differs)

[eluser]dexcell[/eluser]
^
I also think no need for you to maintain the compability with CI AR, if you can do MORE with IQ hehe Smile
better spend the time somewhere. Smile

[eluser]m4rw3r[/eluser]
I'm going to start and remake a lot of the manual very soon, so here I have a question for you:

What is missing or could be made better in the current manual?

[eluser]r2b2_kvr[/eluser]
hi,
i've tried ignitedrecord last night and it is very good. i have an existing web app consists of 300 plus legacy tables so you can imagine how hard it is to track the relationships between them. i have to use a tool called DBDesigner to map out the relationships. Pulling data involves a lot of joins. Saving the data is another thing. Having said that, IgnitedRecord promises a lot!

I have few questions:
1. How do I autoload related tables / relationship? Im asking about this because i dont want to call $this->related('relation_name') multiple times.

2. How do I view the queries produced by IgnitedRecord ? I currently use ActiveRecord's $this->db->last_query.

3. Do i always have to use the reference operator when calling the related model?
Code:
$obj = $this->model_name->find(1);
$related = &$obj->related('related_model');



Thank you!

[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 =

[eluser]r2b2_kvr[/eluser]
Thanks for the reply. I am gonna try those things that you've recommended.

By the way...

Quote:A notice to all IgnitedRecord users out there!

I’ve dropped support for CodeIgniter’s ActiveRecord lib as SQL builder....

In which version of IR is this be implemented? I am using 0.2.0.


Thanks again!

[eluser]r2b2_kvr[/eluser]
Please include in the manual the following (kindly disregard if its already there Smile )

How to override settings like table name.,etc
How to manipulate data using IR. please also show how to update the related tables
Examples on how to validate data before saving.
Also show the query that IR produces for the relationship. This will help us understand more whats happening behind the scenes
Other IR methods that we can use, and its examples..


I wonder when IR 1.0 will come out ? I really cant wait..

Thank you




Theme © iAndrew 2016 - Forum software by © MyBB