Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce DB calls throughout program #188

Closed
DaneEveritt opened this issue Sep 21, 2014 · 1 comment
Closed

Reduce DB calls throughout program #188

DaneEveritt opened this issue Sep 21, 2014 · 1 comment
Milestone

Comments

@DaneEveritt
Copy link
Contributor

[
  {
    "statement": "SELECT * FROM `acp_settings`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:37",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.core.php:83",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT `id`, `node` FROM `nodes`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:46",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.core.php:83",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `acp_settings`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:37",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.auth.php:198",
          "function": "__construct"
        },
        {
          "file": "src/framework/framework.core.php:84",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT `id`, `node` FROM `nodes`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:46",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.auth.php:198",
          "function": "__construct"
        },
        {
          "file": "src/framework/framework.core.php:84",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `users` WHERE `session_ip` = :sessip AND `session_id` = :session",
    "details": [
      [
        {
          "file": "src/framework/framework.auth.php:256",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.user.php:53",
          "function": "isLoggedIn"
        },
        {
          "file": "src/framework/framework.core.php:85",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `users` WHERE `session_ip` = :sesip AND `session_id` = :sesid",
    "details": [
      [
        {
          "file": "src/framework/framework.user.php:55",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.core.php:85",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `acp_settings`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:37",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.email.php:41",
          "function": "__construct"
        },
        {
          "file": "src/framework/framework.core.php:87",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT `id`, `node` FROM `nodes`",
    "details": [
      [
        {
          "file": "src/framework/framework.settings.php:46",
          "function": "prepare"
        },
        {
          "file": "src/framework/framework.email.php:41",
          "function": "__construct"
        },
        {
          "file": "src/framework/framework.core.php:87",
          "function": "__construct"
        },
        {
          "file": "panel/servers.php:20",
          "function": "require_once"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `users` WHERE `session_ip` = :sessip AND `session_id` = :session",
    "details": [
      [
        {
          "file": "src/framework/framework.auth.php:256",
          "function": "prepare"
        },
        {
          "file": "panel/servers.php:22",
          "function": "isLoggedIn"
        }
      ]
    ]
  },
  {
    "statement": "SELECT * FROM `servers` ORDER BY `active` DESC",
    "details": [
      [
        {
          "file": "panel/servers.php:37",
          "function": "prepare"
        }
      ]
    ]
  }
]
@DaneEveritt
Copy link
Contributor Author

Feel free to use this class for debugging:

    /**
     * @param string $statement
     * @param array $options
     * @return object
     */
    private static $executedQuery = array();
    public function prepare($statement, $options = array()){

        $backtrace = debug_backtrace();
        $internals = array();
        foreach($backtrace as $id => $inner)
            $internals[$id] = array('file' => $inner['file'].":".$inner['line'], 'function' => $inner['function']);

        self::$executedQuery[self::$queryCounter] = array('statement' => $statement, 'details' => array($internals));
        ++self::$queryCounter;
        return parent::prepare($statement, $options);

    }

    public static function listQuery(){

            return self::$executedQuery;

    }

Add both classes to the class databaseInit extends \PDO function in framework.database.connect.php and then call \Database\databaseInit::listQuery() to get the array of all the calls preformed.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant