Welcome Guest, Not a member yet? Register   Sign In
db->select after start_cache and stop_cache ignoring second parameter
#1

[eluser]Unknown[/eluser]
Not sure if this is a bug or not but I'm pretty sure it is. When I try to define a select and use the second parameter to disable backticks after caching parts of my active record query adds the back ticks anyway:

Code:
$CI->db->start_cache();
$CI->db->from('message');
$CI->db->join('user','message.from_user_id = user.user_id');
$CI->db->where('message.to_user_id',$user_id);
if(!is_null($message_parent_uuid)) $CI->db->where('message.parent_message_uuid',$message_parent_uuid);
if(is_array($message_type_id) && count($message_type_id) > 0) $CI->db->where_in('message_type_id',$message_type_id);
elseif($message_type_id != Message::TYPE_UNSPECIFIED) $CI->db->where('message.message_type_id',$message_type_id);
if(isset($filters['read_flg'])) $CI->db->where('message.read_flg',intval($filters['read_flg']));
$CI->db->stop_cache();

$CI->db->select('SQL_CALC_FOUND_ROWS *', FALSE);
$CI->db->get();
$total_query = $CI->db->query('SELECT FOUND_ROWS() as total',FALSE);
$retval['total'] = $total_query->row()->total;

this produces this query to the database:

Code:
SELECT `SQL_CALC_FOUND_ROWS` *
FROM (`message`)
JOIN `user` ON `message`.`from_user_id` = `user`.`user_id`
WHERE `message`.`to_user_id` =  '1'

Which of course fails because SQL_CALC_FOUND_ROWS becomes `SQL_CALC_FOUND_ROWS`.

I have since changed my code to not use the cache, just so it works, but I figured you all might want to know =)





Theme © iAndrew 2016 - Forum software by © MyBB