Welcome Guest, Not a member yet? Register   Sign In
profiler showing queries twice
#1

[eluser]woopsicle[/eluser]
hi all,

when i enable the profiler, the output (at the bottom of the page) shows each query on the page twice.
eg.
query 1
query 2
query 3
query 1
query 2
query 4

it is not affecting my view files.. and all the data being output in the view files is correct. just wondering if i should be worried about this? ... obviously if the queries ARE running twice then it will make my page generation times a bit slower - but i am not sure if this is a bug with the profiler class or with my code!

i have tried debugging but am unable to figure out why this is happening. have tried not using models (just putting the queries in the controller), having a blank view file (i.e. not doing anything with the query data) but it still persists.

any ideas? i have made other CI sites and I cannot remember this happening before... but I can't think of anything which I have done/setup differently for this site.

model eg:
Code:
function getSiteStats()
{
$this->db->select(" num_members,
            num_emails,
            num_attachments,
            num_votes");    
$this->db->from("site_stats");
return $this->db->get();
}


controller eg:
Code:
//site stats
$this->load->model('Stats_Model', 'sql_stats', TRUE);
$this->data['stats'] = $this->sql_stats->getSiteStats();
#2

[eluser]tonanbarbarian[/eluser]
what is the name of the method that is being called in the controller
it is possible that you are using a reserved word as the name of a method and this is resulting in some strange behaviour
i have seen this before
#3

[eluser]woopsicle[/eluser]
hi thanks for the reply..

it is my homepage controller... or index.php

Code:
class Index extends Controller {

    public $data = array();
    
    function index()
    {
        parent::Controller();
        $this->output->enable_profiler(TRUE);
        
        //site stats
        $this->load->model('Stats_Model', 'sql_stats', TRUE);
        $this->data['stats'] = $this->sql_stats->getSiteStats();
        
                //...more code in here....
    
        $this->load->view('index', $this->data);
    }
}
?>

does that help? looking at subpages.. it does seem to only be this homepage that is having the problem.. so i think you are right.. just not sure what i should change it to?
#4

[eluser]tonanbarbarian[/eluser]
ok there is your problem i think
rename the controller from index to something else
i feel the routing may be having problems with the fact that the controller is called index
#5

[eluser]woopsicle[/eluser]
mmm i am not too sure what else i can change it too.. i dont particularly what to change the controller name as it is my homepage.

how does everyone else have their homepage set up?

default_controller (in routes.php) = index
.htaccess to remove index.php
controller called index.php
Code:
class Index extends Controller {
function Index()
{
       parent::Controller();
       ... code ...
}
}
#6

[eluser]John Fuller[/eluser]
I don't see why the default controller has to be named index. Semantically you could be just as correct by calling it main or site or something to that effect. I think you are placing too much importance on the name, users don't care what that first segment is. As long as it is not offensive. Wink
#7

[eluser]wiredesignz[/eluser]
John Fuller is correct, in fact you never have to show your default controller name in the URL, just use site_url() in your links.
#8

[eluser]tonanbarbarian[/eluser]
Problem Solving 101

Step 1: Determine the cause of the problem
Step 2: Create a solution.

You are trying to do step 2 before step 1
Who cares what you eventually call it, have you tried to rename the controller to ANYTHING and see if it is the cause of the problem?

Once you have renamed the controller you will know if that is the cause of the problem.
If it is you can then worry about what to name it.
If it is not then we have to look somewhere else for the cause.
#9

[eluser]woopsicle[/eluser]
thanks john and wiresdesignz!
i have renamed it.. and yes it does work. i needed to change the default_controller to suit this.

i would imagine people calling their homepage controller "index.php" would be fairly common.. so hopefully this thread helps someone else out there too if they experience the same problem.




Theme © iAndrew 2016 - Forum software by © MyBB