CodeIgniter Active Record is easy, well documented and powerful. But when I try to insert MySQL built in functions CONCAT
, NOW
, GROUP_CONCAT
, DATEDIFF
, TRIM
etc or my custom functions it is giving errors. The following code works fine...
$result = $this->db->select('p.first_name, p.last_name, p.mobile_number, p.email_address')->from('profile p')->get()->result();
But When I want to contact first_name
and last_name
and use MySQL CONCAT
function like this...
$result = $this->db->select('CONCAT(p.first_name, " ", p.last_name) fullname, p.mobile_number, p.email_address')->from('profile p')->get()->result();
It is showing database errors
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '", `p`.`last_name)` fullname, `p`.`mobile_number`, `p`.`email_address` FROM (`pr' at line 1
SELECT CONCAT(p.first_name, `"` ", `p`.`last_name)` fullname, `p`.`mobile_number`, `p`.`email_address` FROM (`profile` p)
Filename: D:\xampp\htdocs\example\system\database\DB_driver.php
Line Number: 330
Is there a any way to insert MySQL Functions inside CodeIgniter Active Record? Hope I am clear. Thanks in advance.