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

  • Home
  • SEARCH
  • 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 7793743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:35:01+00:00 2026-06-01T22:35:01+00:00

i am using codeigniter active records to execute a simple mysql query to select

  • 0

i am using codeigniter active records to execute a simple mysql query to select data in last one hour.

so my query is:

SELECT * FROM tablename WHERE added_datetime >= DATE_SUB(NOW(),INTERVAL 1 HOUR)

and my codeigniter code to form this query is:

$data=array(
            'added_datetime >='=>'DATE_SUB(NOW(),INTERVAL 1 HOUR)',

            );
            $query=$this->db->get_where('tablename',$data);

now the issue is codeigniter adds a single quotes around the DATE_SUB function and due to this the query not works on mysql server.

codeigniter produces:

SELECT * FROM (`tablename`) WHERE `added_datetime` >= 'DATE_SUB(NOW(),INTERVAL 1 HOUR)'

i also tried by adding FALSE as 3rd parameter in get_where but stil not worked

$query=$this->db->get_where('tablename',$data,FALSE);

it also produced the same query as above.
So please suggest me how to solve this issue.

-Thanks

  • 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-01T22:35:04+00:00Added an answer on June 1, 2026 at 10:35 pm

    Try doing something like this instead:

    $this->db->where("added_datetime >= DATE_SUB(NOW(),INTERVAL 1 HOUR)", NULL, FALSE);
    $query = $this->db->get('tablename');
    

    $this->db->get_where(); doesn’t provide the function to unescaping your where clause.

    • 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
I have this syntax for grabbing some data from database, I using codeigniter's active
I'm using CodeIgniter's active record features but I'm not able to select the data
I'm using Codeigniter and the Active Record class to build a simple API in
I want to implement a sql query using CodeIgniter Active Record class. The query
I need help building a mysql query to select from multiple tables. I have
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I am trying to form a query using codeigniter's active record, the search is
I'm using Codeigniter's Active Record Class. So the query looks something like this: $query
I believe there is an error in this line in Codeigniter using Active Records,

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.