Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:44:55+00:00 2026-06-08T01:44:55+00:00

CodeIgniter Active Record is easy, well documented and powerful. But when I try to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:44:56+00:00Added an answer on June 8, 2026 at 1:44 am
    • FIXED THE ISSUE

    adding the field names in active record array can fix this problem. inside array you can use any mysql functions. the fix of above.

    MySQL Table :

    fullname             mobile_number  email_address                 
    -------------------  -------------  ------------------------------
    sitaramaiah javvadi  9989403339     gnt.sitaramaiah@mstonline.in  
    raja kumar guthula   9949526012     gnt.rajkumar@mstonline.in     
    chandra sekhar k.l   9912144556     gnt.sekhar@mstonline.in       
    khadar  basha        98884884584    khadar333332@gmail.com        
    super administrator  9841866445     admin@gmail.com
    

    CodeIgniter Active Record :

    $result = $this->db->select(array('CONCAT(p.first_name, " ", p.last_name) `fullname`', 'p.mobile_number', 'p.email_address'))->from('profile `p`')->get()->result();
    echo '<pre>';
    print_r($result);
    

    Output :

    Array
    (
        [0] => stdClass Object
            (
                [fullname] => sitaramaiah javvadi
                [mobile_number] => 9989403339
                [email_address] => gnt.sitaramaiah@mstonline.in
            )
    
        [1] => stdClass Object
            (
                [fullname] => raja kumar guthula
                [mobile_number] => 9949526012
                [email_address] => gnt.rajkumar@mstonline.in
            )
    
        [2] => stdClass Object
            (
                [fullname] => chandra sekhar k.l
                [mobile_number] => 9912144556
                [email_address] => gnt.sekhar@mstonline.in
            )
    
        [3] => stdClass Object
            (
                [fullname] => khadar  basha
                [mobile_number] => 98884884584
                [email_address] => khadar333332@gmail.com
            )
    
        [4] => stdClass Object
            (
                [fullname] => super administrator
                [mobile_number] => 9841866445
                [email_address] => admin@gmail.com
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I want to insert current time in database using mySQL function NOW() in Codeigniter's
I'm using CodeIgniter's active record features but I'm not able to select the data
i have been using codeigniter active record class for database acces, But one thing
I'm using Codeigniter and the Active Record class to build a simple API in
I am using Active Record on CodeIgniter. I am confused on which approach I
I'm trying to perform a fulltext search with codeigniters built in Active Record methods.
I want to implement a sql query using CodeIgniter Active Record class. The query
I really like CodeIgniter's Active Record and how nicely it allows all my needed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.