Use Array Data in CodeIgniter Model as SQL? -


in controller, passing data model using following code:

$data = array(     'gid'   =>  $this->input->post('gid'),     'name'  =>  $this->input->post('name'),     'pic'   =>  $this->input->post('pic'),     'link'  =>  $this->input->post('link') );   var_dump($data); $this->login_model->insert_entry($data); 

in model, want use gid value part of sql statement, so:

$get_gid = $this->db->query('select * users gid = $gid'); 

obviously doesn't work, i'm wondering how gid $data , use in sql statement?

tested using

$get_gid = $this->db->where('gid', $data['gid'])->get('users'); print_r($get_gid); 

however output is:

ci_db_mysql_result object ( [conn_id] => resource id #30 [result_id] => resource id #33 [result_array] => array ( ) [result_object] => array ( ) [custom_result_object] => array ( ) [current_row] => 0 [num_rows] => 0 [row_data] => )

did try gid = $data['gid']

i assume yours model method looks this:

insert_entry($data) {      here active record or query...  } 

if yes try display query see if $data['gid'] visible there

you can try

$this->db->get_compiled_select(); 

or after query runs

$this->db->last_query(); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -