php - Codeigniter command line can't inset to database -


i have function on 'myproject/controllers/sample.php'

public function calltest()  {     $this->load->database();     $this->db->query("insert table_name (client_id, subscription_id, platform, device) values (1, 1, 1, 1)");      $this->load->view('sample'); } 

whenever run on browser (localhost/index.php/sample/calltest), runs , inserts data on table, when use command line (php index.php sample calltest), sql won't run.

i removed database part , shows code view, think correct. if put database logic it, won't run , output blank. no error logs also.

am doing wrong? missing argument? codeigniter version 2.2.6. reference https://www.codeigniter.com/userguide2/general/cli.html

edited: aril 17,2017

i figured out in of environment, command line above works. suspect cause of me converting php 5.5 5.6 in ubuntu 14, of dependencies might not configured correctly.

you need specify controller , function name well,

example

php index.php/sample/calltest 

also need set 1 config variable below

$config['uri_protocol'] = 'auto' 

read document answer hidden there.

now visit site using url similar this:

example.com/index.php/tools/message/to


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -