sql server - Codeigniter - pass single query result to controller with json - if exists -


wanting pass single codeigniter query result controller using json.

my model function is:

 function get_linked_loads_qty($q){  $sql = $this->db->query(" if exists( select qtylinkedorders linked_order_summary join linked_order_lines on linked_order_summary.linkedorderid= linked_order_lines.linked_order_id load_number='$q' ) begin  select qtylinkedorders linked_order_summary join linked_order_lines on linked_order_summary.linkedorderid= linked_order_lines.linked_order_id load_number='$q'  end else begin  select  1 qtylinkedorders customer_order_lines customerorderid='$q' group customerorderid  end          ");      $query = $this->db->get();     if($query->num_rows > 0){         foreach ($query->result_array() $row){             $row_set[] = htmlentities(stripslashes($row[qtylinkedorders])); //build array        }        return $row_set;     }   } 

and controller is:

function get_linked_loads_qty(){      $this->load->model('sales_model');     if (isset($_post['data'])){         $q = strtolower($_post['data']);         $data = $this->sales_model->get_linked_loads_qty($q);         $this->output->set_content_type('application/json')->set_output(json_encode($data));     }  } 

the sql works 100% in mssql. codeigniter error is: <p>error number: 42000</p><p>[microsoft][sql server native client 11.0][sql server]must specify table select from.</p><p>select *</p>

as mentioned query executes in mssql.

any assistance welcome. thanks.

i believe $this->db->get() not needed, , causes error. $this->db->query("blah...") run query , return result. see codeigniter db query docs


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -