Welcome Guest, Not a member yet? Register   Sign In
Page Database records caching problem
#1

[eluser]ConnorD[/eluser]
Hello,

My problem is that it seems like something in my code is caching the database results even though I have Codeigniter and database caching off. I have a database table, with a link in it that updates a name within that specific record. I can tell that it updates the db correctly, but when I click on the link to go back to the page that views the list, it doesn't show the updates information unless I refresh the page.

The problem could have to do with my browser's cache (Mac OSX - Safari), but it does this in all of my browers (FF, Google Chrome, IE).

I have narrowed the possibilities of the problem down to the template library I am using, Google AJAX libraries API (which does some kind of caching thing, but with the javascript files), the Wick library, or my master template html.

Anybody have any ideas?
#2

[eluser]ConnorD[/eluser]
I am using Colin's template library latest version. I doubt that the problem has to do with that because it doesn't do anything with caching (as far as I am concerned).

Lastly, I am not using any type of .htaccess or mod_rewrite.
#3

[eluser]Tom Schlick[/eluser]
being able to see the code would be helpful here
#4

[eluser]ConnorD[/eluser]
My controller (using Colin's template library, most of the code on the last method is the sending of an email, you can ignore that):
Code:
<?php
class Events extends Controller{
    function Events(){
        parent::Controller();
        
        $this->load->model('login_model');
        $this->load->model('events_model');
        $this->load->model('backend_model');
        $this->load->helper('date');
        $this->load->helper('url');
    }
    
    function index(){
        $data = array(
            'events_display' => $this->events_model->getAllEvents()
        );
        
        $this->template->write('title', "ZAB ARTCC - Events");
        $this->template->write('top_title', 'Events');
        $this->template->write_view('content2', 'events/show_events', $data, TRUE);
        
        $this->template->render();
    }
    
    function event_positions($event_id){
        $this->login_model->userAuth();
        
        $data = array(
            'positions_query' => $this->events_model->getPositions($event_id),
            'eventid' => $event_id
        );
        
        $this->template->write('title', 'ZAB Event Sign-up');
        $this->template->write('top_title', $this->events_model->getEventName($event_id) . " Controller Sign Up");
        $this->template->write_view('content2', 'events/signup', $data, TRUE);
        
        $this->template->render();
    }
    
    function sign_position($event_id, $position_name){
        $data = array(
            'name' => $this->login_model->getControllerName(),
            'event_name' => $this->events_model->getEventName($event_id),
            'position' => $position_name
        );
        
        // Send a receipt email
        $this->load->library('email');
        $config['protocol'] = 'mail';
        $config['wordwrap'] = TRUE;
        $config['mailtype'] = 'html';

        $this->email->initialize($config);
        
        // Send the reciept email
        $this->email->from('[email protected]', 'ZAB ARTCC');
        $this->email->to($this->login_model->getControllerEmail());
        
        $this->email->subject('Event Position Sign-Up Receipt');
        $this->email->message($this->load->view('emails/event_signup', $data, TRUE));    
        
        $this->email->send();
        
        $this->events_model->signPosition($event_id, $position_name);
        $this->backend_model->newPost($this->login_model->getControllerName() . ' has signed up to staff ' . $position_name . ' at the ' . $this->events_model->getEventName($event_id) . ' event.');
        
        $this->template->write('title', 'Event Sign-Up: ' . $position_name);
        $this->template->write('top_title', $position_name . ' for ' . $this->events_model->getEventName($event_id));
        $this->template->write('content1', $this->alert->output('You have successfully been signed up for this position!', 'green'));
        
        $this->template->render();
    }
    
    function position_unregister($event_id, $position_name){
        $this->events_model->unsignPosition($event_id, $position_name);
        $this->backend_model->newPost($this->login_model->getControllerName() . ' has un-registered for ' . $position_name . ' in the event ' . $this->events_model->getEventName($event_id));
        
        $this->template->write('title', 'Position Un-Register');
        $this->template->write('top_title', $position_name);
        $this->template->write('content1', $this->alert->output('You have un-registered for this event successfully!', 'green'));
        $this->template->render();
    }
}
?>

My model (using CI's Active Record library):
Code:
<?php
class Events_model extends Model{
    function Events_model(){
        parent::Model();
    }
    
    function getAllEvents(){
        $this->db->limit(3);
        $this->db->order_by('id', 'DESC');
        $query = $this->db->get('zab_events');
        
        return $query;
    }
    
    function getEventName($id){
        $this->db->where('id', $id);
        $query = $this->db->get('zab_events');
        
        foreach($query->result() as $row){
            return $row->name;
        }
    }
    
    function getPositions($event_id){
        $this->db->where('eventid', $event_id);
        $query = $this->db->get('zab_eventposition');
        
        return $query;
    }
    
    function signposition($event_id, $position_name){
        $data = array(
            'person' => $this->login_model->getControllerName()
        );
        $this->db->where('eventid', $event_id);
        $this->db->where('positionname', $position_name);
        
        $this->db->update('zab_eventposition', $data);
    }
    
    function unsignPosition($event_id, $position_name){
        $data = array(
            'person' => ''
        );
        
        $this->db->where('eventid', $event_id);
        $this->db->where('positionname', $position_name);
        
        $this->db->update('zab_eventposition', $data);
    }
}
?>
#5

[eluser]ConnorD[/eluser]
My master template:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
    [removed][removed]
    [removed][removed]

    &lt;title&gt;&lt;?=$title; ?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

<div id="main">

    &lt;!-- Header --&gt;
    <div id="header">

        &lt;!-- Your logo --&gt;
        <h1 id="logo"><a href="#"><span>Albuquerque</span> ARTCC</a></h1>
        <hr class="noscreen" />        

        &lt;!-- Your slogan --&gt;
        <div id="slogan">&lt;?=$topRight ?&gt;</div>
        <hr class="noscreen" />        
        &lt;!-- Hidden navigation --&gt;
        <p class="noscreen noprint"><em>Quick links: <a href="#content">content</a>, <a href="#nav">navigation</a>.</em></p>
        <hr class="noscreen" />

    </div> &lt;!-- /header --&gt;

    &lt;!-- Navigation --&gt;
    <div id="nav">
    
        <ul class="box">
            <li>&lt;?=anchor('', 'Home') ?&gt;</li>
            <li>&lt;?=anchor('events', 'Events') ?&gt;</li>
            <li>&lt;?=anchor('main/controllers', 'Controllers') ?&gt;</li>
            <li>&lt;?=anchor('main/downloads', 'Downloads') ?&gt;</li>
            <li><a href='http://zabartcc.org/forum'>Forum</a></li>
            &lt;!-- Active page (highlighted) --&gt;
        </ul>
        
    <hr class="noscreen" />
    </div> &lt;!-- /nav --&gt;

    &lt;!-- 2 columns (content + sidebar) --&gt;
    <div id="cols" class="box">

        &lt;!-- Content --&gt;
        <div id="content">
        
            <h2 id="content-title">&lt;?=$top_title ?&gt;</h2>
            
            &lt;!-- Perex --&gt;
            <div id="perex" class="box">
            
                <p>
                &lt;?=$content1; ?&gt;
                </p>
            
            </div> &lt;!-- /perex --&gt;

            <hr class="noscreen" />
            
            <div id="content-in">
                &lt;?=$content2 ?&gt;
                
                
                <div id="sections-bottom"></div>
                &lt;!-- Table --&gt;
                <table class="nomb table-style01">
                
                </table>
                
                &lt;!-- Unorder list --&gt;
                <ul class="ul-style01">
                    
                </ul>

            </div> &lt;!-- /content-in --&gt;
              
        </div> &lt;!-- /content --&gt;

        <hr class="noscreen" />

        &lt;!-- Sidebar --&gt;
        <div id="aside">

            &lt;!-- News --&gt;                    
            <h4 id="aside-title">Login</h4>
                <p id='login_area'>
                </p>
                
                [removed]
                    $.post('http://zabartcc.org/zab_new/index.php/login/',
                    function (data){
                        $("#login_area").html(data);
                    });
                [removed]
            
            &lt;!-- Contact --&gt;
            <h4 class="title">Users Online</h4>

            <div class="aside-in">
                <div class="aside-box">


                </div> &lt;!-- /aside-box --&gt;
            </div> &lt;!-- /aside-in --&gt;
  
        </div> &lt;!-- /aside --&gt;
    
    </div> &lt;!-- /cols --&gt;
    
    <div id="cols-bottom"></div>

    <hr class="noscreen" />
    
    &lt;!-- Footer --&gt;
    <div id="footer">

        &lt;!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php --&gt;            
        <p class="f-right"><a href="http://zabartcc.org">ZAB ARTCC (VATSIM)</a></p>
        &lt;!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php --&gt;
        
        <p>&copy;&nbsp;2009 <a href="#">ZAB ARTCC</a></p>

    </div> &lt;!-- /footer --&gt;

</div> &lt;!-- /main --&gt;

&lt;/body&gt;
&lt;/html&gt;

Lastly, just an example of what the embedded views look like:
Code:
&lt;?php foreach($events_display->result() as $row): ?&gt;
    &lt;?php
        if (!$this->login_model->getControllerId()){
            $sign_up = "";
        }else{
            $sign_up = anchor('events/event_positions/' . $row->id, 'Sign Up');
        }
    ?&gt;
        
    <table border='0'>
        <tr><th>&lt;?=$row->name ?&gt; (Date: &lt;?=$row->date ?&gt;)</th></tr>
        <tr><td>&lt;?=$row->description ?&gt;</td></tr>
        <tr><td>&lt;?=$sign_up ?&gt;</td></tr>
    </table>
    <hr />
&lt;?php endforeach; ?&gt;
#6

[eluser]Zeeshan Rasool[/eluser]
well i also some times face same issue. I did'nt get the exact solutions but i am little sure that this can be server problem. Did you test it online or if you check it online then did you test it locally. I had this problem locally but when i test it online it was alright...
So please check it and then confirm about this..

Hope it will help.
#7

[eluser]ConnorD[/eluser]
Thank you for the reply, I haven't tried my application locally, so I will go ahead and do that. I will get back to you later.




Theme © iAndrew 2016 - Forum software by © MyBB