Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter Active Record vs. regular queries

Currently I use CodeIgniter with regular queries, i.e.:

$sql = "
    SELECT *
    FROM my_table
    WHERE item_id > 1
";    
$q = $this->db->query($sql);

I have started looking into ActiveRecord, and it does look nice, and has the advantage of the query being built regardless of which database driver is used - however, I strictly use a single database type per project in general, so this is not really a benefit for me.

I found that regular queries (as I have in my example) are more readable and easier maintained in my opinion, so I am currently thinking of keeping with regular queries.

Besides for the reasons mentioned above, which should I choose, and for what reason(s)?

Thank you

like image 497
Kobus Myburgh Avatar asked Jan 25 '13 13:01

Kobus Myburgh


1 Answers

well for me i prefer running regular queries, CI's active record consumes to much memory. because it will load all result in the memory. If you know what i mean. As for complexity it's better to go with regular query rather sticking to CI's active record sytax.

like image 97
tomexsans Avatar answered Sep 22 '22 15:09

tomexsans