I have this function on 'myproject/controllers/sample.php'
public function callTest()
{
$this->load->database();
$this->db->query("INSERT INTO table_name (client_id, subscription_id, platform, device) VALUES (1, 1, 1, 1)");
$this->load->view('sample');
}
Whenever I run it on the browser (localhost/index.php/sample/callTest), it successfully runs and inserts the data on the table, but when I use command line (php index.php sample callTest), the SQL won't run.
I removed the database part and it shows the code for the view, which I think is correct. But if I put a database logic to it, it won't run and the output is blank. No error logs also.
Am I doing something wrong? Am I missing an argument? My codeigniter version is 2.2.6. This is my reference https://www.codeigniter.com/userguide2/general/cli.html
Edited: Aril 17,2017
I just figured out that in some of environment, the command line above works. I suspect that the cause of this was me converting PHP 5.5 to 5.6 in Ubuntu 14, some of the dependencies might not be configured correctly.