Logo F2FInterview

Codelgnitor Interview Questions

Q   |   QA
‹‹ previous12345678

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.It allows you to design the exact web app you need from the ground up.

Advantages of using codeigniter:

  •     Extensible.
  •     Control of semantics, data storage.
  •     APIs / Data / REST / Web services.
  •     Current, modern tools, cutting edge
  •     Separation of logic/presentation (MVC design pattern)
  •     Convention – structured code, workflow
  •     Reuse/combine content
  •     Allows development of multiple UIs without touching business logic codebase
  •     Robust API / standards / patternsv
  •     DRY (don’t repeat yourself)

Disadvantages of using codeigniter:

  •     Learning curve
  •     Overkill? (depending on goals)

You can use $result->free_result() to free the results, but sometimes this isn’t the root cause of excessive memory usage. Also, some calls (such as INSERTs) do not return a database object, so you can’t free() them. With very many INSERTs this can really bite you, as CI defaults to saving all your queries.

An undocumented CI feature is available to turn this off:

$this->db->save_queries = false;

There may be performance (caching) issues associated with disabling this across the board - ie. caution and experimentation is indicated. 

Answer 1
Turn on profiling (part of the benchmarking class) - this will show the full detail of all the SQL queries for the page.

Answer 2
You can do this before your query:


.. and then this, once you’ve run the query:


You need to use the SQL AS feature, where you assign a new name to a piece of data, viz:

$this->db->select("COUNT('foo') AS foo_count", FALSE);
// Run your query, and then use the foo_count variable.  

‹‹ previous12345678

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: