public function database($data, $time_start, $memory_start = null)
    {
        if (!array_key_exists('Database', $this->Profiler->log_sections)) {
            return ;
        }

        if (!is_string($data)) {
            return ;
        }

        if (!is_float($time_start)) {
            $time_start = $this->Profiler->getMicrotime();
        }

        if ($memory_start === null) {
            // is dev still not using memory start? trigger error.
            trigger_error('You did not enter $memory_start argument for \Rundiz\Profiler\Console->database() method. Please set the $memory_start to memory_get_usage() in your code.', E_USER_NOTICE);
        }
        if (!is_int($memory_start)) {
            $memory_start = memory_get_usage();
        }

        $backtrace = debug_backtrace();
        $trace_items = [];
        if (is_array($backtrace)) {
            foreach ($backtrace as $items) {
                if (is_array($items) && array_key_exists('file', $items) && array_key_exists('line', $items)) {
                    $trace_items[] = ['file' => $items['file'], 'line' => $items['line']];
                }
            }
        }
        unset($backtrace, $items);

        $section_database = $this->Profiler->log_sections['Database'];
        $section_database_data = [];
        $section_database_data[] = [
            'data' => $data,
            'memory_start' => $memory_start,
            'memory' => memory_get_usage(),// @deprecated [rundizprofiler] and will be removed in the future
            'memory_end' => memory_get_usage(),
            'time_start' => $time_start,
            'time_end' => $this->Profiler->getMicrotime(),
            'call_trace' => $trace_items,
        ];
        $section_database = array_merge($section_database, $section_database_data);

        $this->Profiler->log_sections['Database'] = $section_database;
        unset($section_database, $section_database_data, $trace_items);

        //$this->writeLogSections('Database', $data, $file, $line);
    }
public function database($data, $time_start, $memory_start = null)
    {
        if (!array_key_exists('Database', $this->Profiler->log_sections)) {
            return ;
        }

        if (!is_string($data)) {
            return ;
        }

        if (!is_float($time_start)) {
            $time_start = $this->Profiler->getMicrotime();
        }

        if ($memory_start === null) {
            // is dev still not using memory start? trigger error.
            trigger_error('You did not enter $memory_start argument for \Rundiz\Profiler\Console->database() method. Please set the $memory_start to memory_get_usage() in your code.', E_USER_NOTICE);
        }
        if (!is_int($memory_start)) {
            $memory_start = memory_get_usage();
        }

        $backtrace = debug_backtrace();
        $trace_items = [];
        if (is_array($backtrace)) {
            foreach ($backtrace as $items) {
                if (is_array($items) && array_key_exists('file', $items) && array_key_exists('line', $items)) {
                    $trace_items[] = ['file' => $items['file'], 'line' => $items['line']];
                }
            }
        }
        unset($backtrace, $items);

        $section_database = $this->Profiler->log_sections['Database'];
        $section_database_data = [];
        $section_database_data[] = [
            'data' => $data,
            'memory_start' => $memory_start,
            'memory' => memory_get_usage(),// @deprecated [rundizprofiler] and will be removed in the future
            'memory_end' => memory_get_usage(),
            'time_start' => $time_start,
            'time_end' => $this->Profiler->getMicrotime(),
            'call_trace' => $trace_items,
        ];
        $section_database = array_merge($section_database, $section_database_data);

        $this->Profiler->log_sections['Database'] = $section_database;
        unset($section_database, $section_database_data, $trace_items);

        //$this->writeLogSections('Database', $data, $file, $line);
    }
public function database ( $ data , $ time_start , $ memory_start = null ) { if ( ! array_key_exists ( 'Database' , $ this -> Profiler -> log_sections ) ) { return ; } if ( ! is_string ( $ data ) ) { return ; } if ( ! is_float ( $ time_start ) ) { $ time_start = $ this -> Profiler -> getMicrotime ( ) ; } if ( $ memory_start === null ) { // is dev still not using memory start? trigger error. trigger_error ( 'You did not enter $memory_start argument for \Rundiz\Profiler\Console->database() method. Please set the $memory_start to memory_get_usage() in your code.' , E_USER_NOTICE ) ; } if ( ! is_int ( $ memory_start ) ) { $ memory_start = memory_get_usage ( ) ; } $ backtrace = debug_backtrace ( ) ; $ trace_items = [ ] ; if ( is_array ( $ backtrace ) ) { foreach ( $ backtrace as $ items ) { if ( is_array ( $ items ) && array_key_exists ( 'file' , $ items ) && array_key_exists ( 'line' , $ items ) ) { $ trace_items [ ] = [ 'file' => $ items [ 'file' ] , 'line' => $ items [ 'line' ] ] ; } } } unset ( $ backtrace , $ items ) ; $ section_database = $ this -> Profiler -> log_sections [ 'Database' ] ; $ section_database_data = [ ] ; $ section_database_data [ ] = [ 'data' => $ data , 'memory_start' => $ memory_start , 'memory' => memory_get_usage ( ) , // @deprecated [rundizprofiler] and will be removed in the future 'memory_end' => memory_get_usage ( ) , 'time_start' => $ time_start , 'time_end' => $ this -> Profiler -> getMicrotime ( ) , 'call_trace' => $ trace_items , ] ; $ section_database = array_merge ( $ section_database , $ section_database_data ) ; $ this -> Profiler -> log_sections [ 'Database' ] = $ section_database ; unset ( $ section_database , $ section_database_data , $ trace_items ) ; //$this->writeLogSections('Database', $data, $file, $line); }
Database profiling log.

@param string $data SQL query statement. for example: SELECT id FROM people;.
@param double $time_start `microtime(true)` at before start the query.
@param integer $memory_start `memory_get_usage()` at before start the query. If this was not set then it will not be showing the real memory start. (Required).
@todo [rundizprofiler] the "memory" in array key for Database will be remove in future version.
Database profiling log .