/** * Compiles and returns the tags. * * @return array */ public function getTags() { // Get affected database and tables, add prefixes $database = $this->prefix($this->reflector->getDatabase(), self::PREFIX_DATABASE); // Get affected tables, don't add prefixes yes $tables = $this->reflector->getTables(); // If rows should not be considered, we don't have to differ between specific and unspecific queries // We can simply prefix all tables with the database and return them if ($this->considerRows === false) { return $this->prefix($tables, $database); } // Get affected rows as multidimensional array per table $rows = $this->reflector->getRows(); // Create the table tags with corresponding prefix // Depending on whether the queries are specific or not $tags = $this->getTableTags($tables, $rows); // Then we loop trough all these tags and add a tag for each row // Consisting of the prefixed table and the row with prefix foreach ($tables as $table) { if (!isset($rows[$table])) { continue; } $tablePrefix = $this->prefix($table, self::PREFIX_TABLE_SPECIFIC); $rowPrefix = $this->prefix(self::PREFIX_ROW, $tablePrefix); $tags = array_merge($tags, $this->prefix($rows[$table], $rowPrefix)); } return $this->prefix($tags, $database); }
/** * Returns the hash. * * @return string */ public function getHash() { // Never remove the database from the identifier // Most SQL queries do not include the target database $identifier = $this->reflector->getDatabase() . $this->reflector->getSql() . serialize($this->reflector->getParameters()); return md5($identifier); }
/** * Compiles and returns the tags. * * @return array */ public function getTags() { $tags = []; // Get affected database and tables, add prefixes $tables = $this->prefix($this->reflector->getTables(), self::PREFIX_TABLE); $database = $this->prefix($this->reflector->getDatabase(), self::PREFIX_DATABASE); // If no rows are available or rows should not be considered // Let's just return the database and table tags $rows = $this->reflector->getRows(); if (empty($rows) || $this->considerRows === false) { return $this->prefix($tables, $database); } // Else loop trough tables and create a tag for each row foreach ($tables as $table) { $tags = array_merge($tags, $this->prefix($rows, $this->prefix(self::PREFIX_ROW, $table))); } // Add tables to tags if requested if ($this->considerTables) { $tags = array_merge($tables, $tags); } return $this->prefix($tags, $database); }