public function store()
    {
        if (!$this->_runtime_queries || $this->already_saved) {
            // No queries to save or already saved
            return;
        }

        // Prevent recursive saves
        $this->already_saved = true;

        $path = defined('PATH') ? PATH : (defined('PATH_INTERNAL') ? PATH_INTERNAL : '');

        $objects = [];
        foreach ($this->_runtime_queries as $query) {
            $query_obj = new DbQueryAnalyzerEntity;
            $query_obj->loadDataFromArray([
                'hash' => md5($query['query']),
                'query' => $query['query'],
                'tt' => round($query['run_time'], 3),
                'path' => $path,
            ]);

            $objects[] = $query_obj;
        }

        // Reset queue
        $this->_runtime_queries = [];

        // Save collected objects
        if ($objects) {
            $query_repository = new DbQueryAnalyzerEntityRepository;
            $query_repository->setCollectedObjects($objects);
            $query_repository->save(); // Save all objects
        }
    }
public function store()
    {
        if (!$this->_runtime_queries || $this->already_saved) {
            // No queries to save or already saved
            return;
        }

        // Prevent recursive saves
        $this->already_saved = true;

        $path = defined('PATH') ? PATH : (defined('PATH_INTERNAL') ? PATH_INTERNAL : '');

        $objects = [];
        foreach ($this->_runtime_queries as $query) {
            $query_obj = new DbQueryAnalyzerEntity;
            $query_obj->loadDataFromArray([
                'hash' => md5($query['query']),
                'query' => $query['query'],
                'tt' => round($query['run_time'], 3),
                'path' => $path,
            ]);

            $objects[] = $query_obj;
        }

        // Reset queue
        $this->_runtime_queries = [];

        // Save collected objects
        if ($objects) {
            $query_repository = new DbQueryAnalyzerEntityRepository;
            $query_repository->setCollectedObjects($objects);
            $query_repository->save(); // Save all objects
        }
    }
public function store ( ) { if ( ! $ this -> _runtime_queries || $ this -> already_saved ) { // No queries to save or already saved return ; } // Prevent recursive saves $ this -> already_saved = true ; $ path = defined ( 'PATH' ) ? PATH : ( defined ( 'PATH_INTERNAL' ) ? PATH_INTERNAL : '' ) ; $ objects = [ ] ; foreach ( $ this -> _runtime_queries as $ query ) { $ query_obj = new DbQueryAnalyzerEntity ; $ query_obj -> loadDataFromArray ( [ 'hash' => md5 ( $ query [ 'query' ] ) , 'query' => $ query [ 'query' ] , 'tt' => round ( $ query [ 'run_time' ] , 3 ) , 'path' => $ path , ] ) ; $ objects [ ] = $ query_obj ; } // Reset queue $ this -> _runtime_queries = [ ] ; // Save collected objects if ( $ objects ) { $ query_repository = new DbQueryAnalyzerEntityRepository ; $ query_repository -> setCollectedObjects ( $ objects ) ; $ query_repository -> save ( ) ; // Save all objects } }
Save all queries to DB
Save all queries to DB