Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * Checks if the tables returned by the reflector are cachable.
  *
  * If "include-tables" are available, it will only return true if ALL affected tables exists in "include-tables".
  * If "exclude-tables" are enabled, it will only return false if ANY affected table exists in "exclude-tables".
  *
  * @return bool
  */
 private function tablesCachable()
 {
     $tables = $this->reflector->getTables();
     if ($this->isInclusive()) {
         foreach ($tables as $table) {
             if (!$this->tableIncluded($table)) {
                 return false;
             }
         }
         return true;
     }
     foreach ($tables as $table) {
         if ($this->tableExcluded($table)) {
             return false;
         }
     }
     return true;
 }