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 6821699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:34:32+00:00 2026-05-26T21:34:32+00:00

I want to cache a query in CodeIgniter. What I did for my test

  • 0

I want to cache a query in CodeIgniter. What I did for my test is make a controller, that I named show.php:

class Show extends CI_Controller{
public function __construct() 
{
    parent::__construct();
    $this->load->model('rejaal_show');
}

public function _remap($method = '',$param = array())
{
    $method = intval($method);
    $this->output->cache(5);
    var_dump ($this->rejaal_show->temp($method));
}
}

And a model that I named rejaal_show.php:

public function temp($id)
{
    $this->db->cache_on();
    $this->db->where('id',$id);
    $query = $this->db->get('system_store_table');
    return $query->result();
}

When I call http://localhost/rejaal/show/1 for the first time, it will show a result, but when I call it for the second time, it does not show anything.

I should delete the query cache file to show it again? How should I solve this problem?

With special thanks for your attention.

  • 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-05-26T21:34:33+00:00Added an answer on May 26, 2026 at 9:34 pm

    Can you confirm that you have set $db['default']['cachedir'] to the path of a writable folder in application/config/database.php and that when the query is first run it creates a cache file in there?

    The only other reason I can think of for it failing is by your use of the _remap override. I have not used db caching using _remap, but know that CodeIgniter creates a folder called controller+action in your cache folder, and might not be handled very well if using remap? Someone correct me if I am wrong about this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im doing a database class in PHP and I want to make cache of
I am newer for php. I want make php page cache, query data from
I want to cache query results so that the same results are fetched for
I have very simple query. I want to make sure that I don't have
I want to implement a two-pass cache system: The first pass generates a PHP
I have a query that I want to execute that fastest possible. Here it
I want to query an nhibernate mapped class but the result should be an
<?php header('Cache-Control: no-cache, must-revalidate'); header('Content-type: application/json'); if((@$_GET['query'])) { $query = @$_GET['query']; $mysqli = new
I want to use Second level Cache for my query with eager loading(query is
Is any way to remove cache for a specific named query? I don't really

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.