コード例 #1
0
ファイル: PdoDatabase.php プロジェクト: Austin503/waca
    /**
     * Summary of prepare
     * @param string $statement 
     * @param array $driver_options 
     * @return PDOStatement
     */
    public function prepare($statement, $driver_options = array())
    {
        global $enableQueryLog;
        if ($enableQueryLog) {
            try {
                if ($this->queryLogStatement === null) {
                    $this->queryLogStatement = parent::prepare(<<<SQL
\t\t\t\t\t\t\tINSERT INTO applicationlog (source, message, stack, request, request_ts) 
\t\t\t\t\t\t\tVALUES (:source, :message, :stack, :request, :rqts);
SQL
);
                }
                $this->queryLogStatement->execute(array(":source" => "QueryLog", ":message" => $statement, ":stack" => DebugHelper::getBacktrace(), ":request" => $_SERVER["REQUEST_URI"], ":rqts" => $_SERVER["REQUEST_TIME_FLOAT"]));
            } catch (Exception $ex) {
                trigger_error("Error logging query. Disabling for this request. " . $ex->getMessage(), E_USER_NOTICE);
                $enableQueryLog = false;
            }
        }
        return parent::prepare($statement, $driver_options);
    }