Ejemplo n.º 1
0
 /**
  * Loads complete URL alias data by given array of path hashes.
  *
  * @param string[] $urlHashes URL string hashes
  *
  * @return array
  */
 public function loadUrlAliasData(array $urlHashes)
 {
     /** @var $query \ezcQuerySelect */
     $query = $this->dbHandler->createSelectQuery();
     $count = count($urlHashes);
     foreach ($urlHashes as $level => $urlPartHash) {
         $tableName = "ezurlalias_ml" . ($level === $count - 1 ? "" : $level);
         if ($level === $count - 1) {
             $query->select($this->dbHandler->quoteColumn("id", $tableName), $this->dbHandler->quoteColumn("link", $tableName), $this->dbHandler->quoteColumn("is_alias", $tableName), $this->dbHandler->quoteColumn("alias_redirects", $tableName), $this->dbHandler->quoteColumn("is_original", $tableName), $this->dbHandler->quoteColumn("action", $tableName), $this->dbHandler->quoteColumn("action_type", $tableName), $this->dbHandler->quoteColumn("lang_mask", $tableName), $this->dbHandler->quoteColumn("text", $tableName), $this->dbHandler->quoteColumn("parent", $tableName), $this->dbHandler->quoteColumn("text_md5", $tableName))->from($this->dbHandler->quoteTable("ezurlalias_ml"));
         } else {
             $query->select($this->dbHandler->aliasedColumn($query, "id", $tableName), $this->dbHandler->aliasedColumn($query, "link", $tableName), $this->dbHandler->aliasedColumn($query, "is_alias", $tableName), $this->dbHandler->aliasedColumn($query, "alias_redirects", $tableName), $this->dbHandler->aliasedColumn($query, "is_original", $tableName), $this->dbHandler->aliasedColumn($query, "action", $tableName), $this->dbHandler->aliasedColumn($query, "action_type", $tableName), $this->dbHandler->aliasedColumn($query, "lang_mask", $tableName), $this->dbHandler->aliasedColumn($query, "text", $tableName), $this->dbHandler->aliasedColumn($query, "parent", $tableName), $this->dbHandler->aliasedColumn($query, "text_md5", $tableName))->from($query->alias("ezurlalias_ml", $tableName));
         }
         $query->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn("text_md5", $tableName), $query->bindValue($urlPartHash, null, \PDO::PARAM_STR)), $query->expr->eq($this->dbHandler->quoteColumn("parent", $tableName), isset($previousTableName) ? $this->dbHandler->quoteColumn("link", $previousTableName) : $query->bindValue(0, null, \PDO::PARAM_INT))));
         $previousTableName = $tableName;
     }
     $query->limit(1);
     $statement = $query->prepare();
     $statement->execute();
     return $statement->fetch(\PDO::FETCH_ASSOC);
 }
Ejemplo n.º 2
0
 /**
  * Creates an array of select columns for $tableName.
  *
  * @param \ezcQuerySelect $q
  * @param string $tableName
  */
 protected function selectColumns(ezcQuerySelect $q, $tableName)
 {
     foreach ($this->columns[$tableName] as $col) {
         $q->select($this->dbHandler->aliasedColumn($q, $col, $tableName));
     }
 }