Pimcore\Db::stopCapturingDefinitionModifications PHP Method

stopCapturingDefinitionModifications() public static method

public static stopCapturingDefinitionModifications ( $connection )
    public static function stopCapturingDefinitionModifications($connection)
    {
        if (self::$_logCaptureActive) {
            $query = $connection->getProfiler()->getLastQueryProfile()->getQuery();
            $params = $connection->getProfiler()->getLastQueryProfile()->getQueryParams();
            // @TODO named parameters
            if (!empty($params)) {
                for ($i = 1; $i <= count($params); $i++) {
                    $query = substr_replace($query, $connection->quote($params[$i]), strpos($query, "?"), 1);
                }
            }
            self::logDefinitionModification($query);
            $connection->getProfiler()->setEnabled(self::$_logProfilerWasEnabled);
        }
        self::$_logCaptureActive = false;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function callResourceMethod($method, $args)
 {
     $resource = $this->getResource();
     if ($this->inTransaction || Db::isWriteQuery($method, $args)) {
         $resource = $this->getWriteResource();
     }
     $capture = false;
     if (\Pimcore::inAdmin()) {
         $methodsToCheck = array("query", "update", "delete", "insert");
         if (in_array($method, $methodsToCheck)) {
             $capture = true;
             Db::startCapturingDefinitionModifications($resource, $method, $args);
         }
     }
     $r = call_user_func_array(array($resource, $method), $args);
     if (\Pimcore::inAdmin() && $capture) {
         Db::stopCapturingDefinitionModifications($resource);
     }
     return $r;
 }