connection = $connection; $this->request = $request; } public function root(?TimelineRoot $override = null): TimelineRoot { if (null !== $override) { $this->_root = $override; } if (null === $this->_root) { $this->_root = new TimelineRoot(); $this->_root->populate(); } if (!$this->_rootEmptyAllowed && $this->_root->isEmpty()) { throw new \Exception('No valid root folder found (.nomedia?)'); } return $this->_root; } public function allowEmptyRoot(bool $value = true) { $this->_rootEmptyAllowed = $value; } public function getBuilder() { return $this->connection->getQueryBuilder(); } public static function debugQuery(IQueryBuilder &$query, string $sql = '') { // Print the query and exit $sql = empty($sql) ? $query->getSQL() : $sql; $sql = str_replace('*PREFIX*', 'oc_', $sql); $sql = self::replaceQueryParams($query, $sql); echo "{$sql}"; exit; // only for debugging, so this is okay } public static function replaceQueryParams(IQueryBuilder &$query, string $sql) { $params = $query->getParameters(); foreach ($params as $key => $value) { if (\is_array($value)) { $value = implode(',', $value); } elseif (\is_bool($value)) { $value = $value ? '1' : '0'; } elseif (null === $value) { $value = 'NULL'; } $value = $query->getConnection()->getDatabasePlatform()->quoteStringLiteral($value); $sql = str_replace(':'.$key, $value, $sql); } return $sql; } }