Skip to content

Commit

Permalink
add properties to ViewRawStructure
Browse files Browse the repository at this point in the history
  • Loading branch information
howyi committed Oct 10, 2017
1 parent b7b1af5 commit 23541ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Conv/Factory/ViewStructureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public static function fromSpec(string $viewName, array $spec): ViewStructureInt
} else {
return new ViewRawStructure(
$viewName,
$spec[SchemaKey::VIEW_RAW_QUERY]
$spec[SchemaKey::VIEW_RAW_QUERY],
array_diff_key($spec, [SchemaKey::VIEW_RAW_QUERY])
);
}
}
Expand All @@ -50,7 +51,8 @@ public static function fromView(\PDO $pdo, string $dbName, string $viewName): Vi
$createQuery = $pdo->query("SHOW CREATE VIEW $viewName")->fetch()['Create View'];
return new ViewRawStructure(
$viewName,
"$createQuery;"
"$createQuery;",
[]
);
}
}
14 changes: 13 additions & 1 deletion src/Conv/Structure/ViewRawStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ class ViewRawStructure implements ViewStructureInterface, TableStructureInterfac
{
private $viewName;
private $createQuery;
private $properties;

/**
* @param string $viewName
* @param string $createQuery
* @param array $properties
*/
public function __construct(
string $viewName,
string $createQuery
string $createQuery,
array $properties
) {
$this->viewName = $viewName;
$this->createQuery = $createQuery;
$this->properties = $properties;
}

/**
Expand Down Expand Up @@ -74,4 +78,12 @@ public function getCompareQuery(): string
$compareQuery = str_replace([$definer, PHP_EOL, ' '], '', $this->createQuery);
return rtrim($compareQuery, ';');
}

/**
* @return array
*/
public function getProperties(): array
{
return $this->properties;
}
}

0 comments on commit 23541ef

Please sign in to comment.