How is the first query different from the second query in CodeIgniter?
Raw SQL in query()
:
$query = $this->db->query('SELECT * FROM my_table WHERE email = $email LIMIT 1');
Active record:
$query = $this->db
->where('email', $email)
->limit(1)
->get('my_table');
There's really no difference.
Enable the profiler and you will be able to see the actual queries run.
Active record is easier to use when building a query dynamically, and escapes the parameters automatically. Using $this->db->query()
you must escape it yourself unless you want to use query bindings (see bottom of page).
Some queries are just to complicated to use Active Record efficiently, but not this one. Use whichever method you want, but my vote is for Active Record.