简体   繁体   中英

Internal server error 500 on codeigniter Query

I am using ajax to retreive data from the database and am receiving a weird internal server error 500 on this query and I can't figure out what is wrong with it. The issue is with ->get()->result() , when I remove that I am not getting a internal server error as response. The whole query:

$this->db->select('bikes.store_id')->from('mappings')->where('mappings.product_id', $prod_id)->join('bikes', 'bikes.product_id = mappings.product_id')->get()->result()

Your joining query is incorrect.

$this->db->select('bikes.store_id')->from('mappings')->join('bikes', 'bikes.product_id = mappings.product_id')->where('mappings.product_id', $prod_id)->get()->result();

Try out this query.

Write below in your controller to see what query is being generated.

$this->output->enable_profiler(TRUE);

Try this code, you misplaces something :

$this->db->select('bikes.store_id')->from('mappings')->join('bikes', 'bikes.product_id = mappings.product_id','left')->where('mappings.product_id', $prod_id);
$result = $this->db->get()->result();

You can get the data using $result indeed.

$this->db->select('bikes.store_id');
$this->db->from('mappings');
$this->db->join('bikes', 'bikes.product_id = mappings.product_id','left');
$this->db->where('mappings.product_id', $prod_id);
$query = $this->db->get();
return $query->result();

try this out.If it does not work try echo $this->db->last_query(); to get the last SQL query.Get back with the error.Hope it solves your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM