Welcome Guest, Not a member yet? Register   Sign In
Active record vs SQL
#2

[eluser]xwero[/eluser]
It's up to you. The query method has bindings to escape the values too so that is not the reason.

i think the main reason to use AR, for me at least, is to write less code
Code:
$query = $this->db->query('SELECT field1, field2 FROM table');
// VS
$query = $this->db->select('field1, field2')->get('table');
The AR methods are more readable for some and they encourage writing safer sql statements. You can also cache portions of the sql statement which means even less code.
Because you build the sql statement with methods it's easier to add or remove a portion. With the query method you have to build the sql statement without any help.

Whatever you choose try to be as consistent as possible. The query method can handle all the queries but AR can't because there were decisions to have the methods available for different databases. Not all methods are supported by all databases but most are.


Messages In This Thread
Active record vs SQL - by El Forum - 06-23-2008, 04:00 AM
Active record vs SQL - by El Forum - 06-23-2008, 04:23 AM
Active record vs SQL - by El Forum - 06-23-2008, 10:46 AM
Active record vs SQL - by El Forum - 06-23-2008, 06:36 PM
Active record vs SQL - by El Forum - 06-23-2008, 08:05 PM
Active record vs SQL - by El Forum - 06-23-2008, 11:31 PM
Active record vs SQL - by El Forum - 06-24-2008, 03:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB