Welcome Guest, Not a member yet? Register   Sign In
want to use database Active Record class but need to perform non-standard MySQL function
#1

[eluser]gloosemo[/eluser]
I want to perform a query and concatenate 2 columns. The query is as follows:

Code:
$query = "SELECT id, foodid, CONCAT(c1, ' ', c2) AS consume, mealtime, comb FROM " .
$user . "_consump WHERE id > $start ORDER BY id desc";
Can i perform this query using Active Record? I don't know how to get CONCAT in there. I've tried:
Code:
$this->db->select("id, foodid, CONCAT(c1, ' ', c2) AS consume, mealtime,

comb")->where('id',$start)->order_by('id','desc');

but that produces some unwanted quotes in the CONCAT part, it actually ends up as:
Code:
SELECT `id`, `foodid`, CONCAT(c1, `'` ', `c2)` AS consume, `mealtime`, `comb` FROM
(`consump`) WHERE `id` = -249 ORDER BY `id` desc




Theme © iAndrew 2016 - Forum software by © MyBB