Welcome Guest, Not a member yet? Register   Sign In
[CI4] Toolbar DB Query And Event Duplication
#1

(This post was last modified: 10-15-2020, 04:35 PM by Awlikhaleghi.)

Hi everybody.
I'm relatively new with the CI4, I've been learning it as I go and to be honest loving the changes so far.

My DB Queries are happening twice, no matter where they're executed from.
[Image: screenshot-from-2020-10-16-02-34-51.png]

these queries are being executed from several different files.
the function which runs the query is a helper as follows:
PHP Code:
function getOption(string $key)
{
    return model("OptionsModel",TRUE)->getOption($key);


and the `getOption()` function inside OptionsModel is as:
PHP Code:
public function getOption(string $key){
        if(isset(self::$loadedOptions[$key]))
            return self::$loadedOptions[$key];

        $row $this->select('option_value')
            ->where("option_key",$key)
            ->get()
        ->getRow();

        if(!$row)
            return false;

        self::$loadedOptions[$key] = $row->option_value;

        return $row->option_value;
    
Even though these functions themselves are not the problem, I wanted to explain anyways.
no matter how the query is being executed, the CI4 toolbar is always recording two of each SELECT query.
my inserts are fine and are happening only once.

and also my Events are happening twice as well.
Meaning having the following code in a view file:

PHP Code:
\CodeIgniter\Events\Events::trigger('TEST'); 
and having the following code in the Events.php
PHP Code:
Events::on('TEST', function () {
 echo 
"ON TEST EXECUTION.";
}); 
would produce "ON TEST EXECUTION.ON TEST EXECUTION." upon triggering TEST in view file.

if anyone can point me to the right direction so I can troubleshoot this it'd be greatly appreacated.
Reply


Messages In This Thread
[CI4] Toolbar DB Query And Event Duplication - by Awlikhaleghi - 10-15-2020, 04:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB