[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?
[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.
[eluser]Tom Schlick[/eluser]
being able to see the code would be helpful here
[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);
}
}
?>
[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">
<html >
<head>
[removed][removed]
[removed][removed]
<title><?=$title; ?></title>
</head>
<body>
<div id="main">
<!-- Header -->
<div id="header">
<!-- Your logo -->
<h1 id="logo"><a href="#"><span>Albuquerque</span> ARTCC</a></h1>
<hr class="noscreen" />
<!-- Your slogan -->
<div id="slogan"><?=$topRight ?></div>
<hr class="noscreen" />
<!-- Hidden navigation -->
<p class="noscreen noprint"><em>Quick links: <a href="#content">content</a>, <a href="#nav">navigation</a>.</em></p>
<hr class="noscreen" />
</div> <!-- /header -->
<!-- Navigation -->
<div id="nav">
<ul class="box">
<li><?=anchor('', 'Home') ?></li>
<li><?=anchor('events', 'Events') ?></li>
<li><?=anchor('main/controllers', 'Controllers') ?></li>
<li><?=anchor('main/downloads', 'Downloads') ?></li>
<li><a href='http://zabartcc.org/forum'>Forum</a></li>
<!-- Active page (highlighted) -->
</ul>
<hr class="noscreen" />
</div> <!-- /nav -->
<!-- 2 columns (content + sidebar) -->
<div id="cols" class="box">
<!-- Content -->
<div id="content">
<h2 id="content-title"><?=$top_title ?></h2>
<!-- Perex -->
<div id="perex" class="box">
<p>
<?=$content1; ?>
</p>
</div> <!-- /perex -->
<hr class="noscreen" />
<div id="content-in">
<?=$content2 ?>
<div id="sections-bottom"></div>
<!-- Table -->
<table class="nomb table-style01">
</table>
<!-- Unorder list -->
<ul class="ul-style01">
</ul>
</div> <!-- /content-in -->
</div> <!-- /content -->
<hr class="noscreen" />
<!-- Sidebar -->
<div id="aside">
<!-- News -->
<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]
<!-- Contact -->
<h4 class="title">Users Online</h4>
<div class="aside-in">
<div class="aside-box">
</div> <!-- /aside-box -->
</div> <!-- /aside-in -->
</div> <!-- /aside -->
</div> <!-- /cols -->
<div id="cols-bottom"></div>
<hr class="noscreen" />
<!-- Footer -->
<div id="footer">
<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->
<p class="f-right"><a href="http://zabartcc.org">ZAB ARTCC (VATSIM)</a></p>
<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->
<p>© 2009 <a href="#">ZAB ARTCC</a></p>
</div> <!-- /footer -->
</div> <!-- /main -->
</body>
</html>
Lastly, just an example of what the embedded views look like:
Code: <?php foreach($events_display->result() as $row): ?>
<?php
if (!$this->login_model->getControllerId()){
$sign_up = "";
}else{
$sign_up = anchor('events/event_positions/' . $row->id, 'Sign Up');
}
?>
<table border='0'>
<tr><th><?=$row->name ?> (Date: <?=$row->date ?>)</th></tr>
<tr><td><?=$row->description ?></td></tr>
<tr><td><?=$sign_up ?></td></tr>
</table>
<hr />
<?php endforeach; ?>
[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.
[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.
|