示例#1
0
 /**
  * Returns the prefixed table tags for a set of tables and rows.
  *
  * @param array $tables The tables to be tagged
  * @param array $rows   A multidimensional array containing the rows per table
  *
  * @return array
  */
 private function getTableTags($tables, $rows)
 {
     $tags = [];
     $type = $this->reflector->getType();
     foreach ($tables as $table) {
         $isSpecific = isset($rows[$table]) && !empty($rows[$table]);
         // These types of queries require a specific tag
         if ($type === Reflector::QUERY_TYPE_SELECT && $isSpecific || $type === Reflector::QUERY_TYPE_UPDATE && !$isSpecific || $type === Reflector::QUERY_TYPE_DELETE && !$isSpecific || $type === Reflector::QUERY_TYPE_TRUNCATE) {
             $tags[] = $this->prefix($table, self::PREFIX_TABLE_SPECIFIC);
         }
         // While these ones require an unspecific one
         if ($type === Reflector::QUERY_TYPE_SELECT && !$isSpecific || $type === Reflector::QUERY_TYPE_UPDATE || $type === Reflector::QUERY_TYPE_DELETE || $type === Reflector::QUERY_TYPE_INSERT) {
             $tags[] = $this->prefix($table, self::PREFIX_TABLE_UNSPECIFIC);
         }
     }
     return $tags;
 }