codeigniter mysql views vs query codeigniter mysql views vs query codeigniter codeigniter

codeigniter mysql views vs query


  1. MySQL views are queried the same way as tables, on a side note, you can't have a table and a view share the same name.
  2. Depends on the query you use in the view, views can be internally cached so in the long run - yes, they are faster.
  3. Best practice in this case is to use whatever you find easy to use for yourself and your team, I personally stick to using $this->db->query(); as I find it's easier to change a simple query of this kind to have some advanced functionality like sub-queries or other things that are hard and/or impossible to do with CI query builder. My advice would be to stick to one way of queries - if you use ->query(), then use them everywhere, if you use a query builder, then use it wherever it is possible to achieve the result using it.