Welcome Guest, Not a member yet? Register   Sign In
MySQL commend to CodeIgniter
#3

The previous answer shows how to build the statement using Query Builder (QB). QB is a great tool but a lot of the time it is not necessary. Consider what QB does - it builds query statements, which are strings used to pass commands to a database.

When the required query statement is simple and won't need to be dynamically altered then QB is serious overkill. The previous answer, while completely correct, will result in a lot of code (hundreds of lines?) being executed in order to produce the string "SELECT COUNT(*) FROM job_progress WHERE status='Runing'". It also required a lot of typing to code all those QB calls.

QB will eventually use the string it builds as an argument to the method query(). Why not remove the middle-man and go straight to that method?

PHP Code:
return $this->db
             
->query("SELECT COUNT(*) FROM job_progress WHERE status='Runing'")
 
            ->result(); 
Reply


Messages In This Thread
MySQL commend to CodeIgniter - by azmath - 05-30-2018, 01:55 AM
RE: MySQL commend to CodeIgniter - by Krycek - 05-30-2018, 03:09 AM
RE: MySQL commend to CodeIgniter - by dave friend - 05-30-2018, 07:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB