public function resolveTables(array $list, array $definitions = array(), array $resolved = array())
{
if ($this->_tables === null) {
$this->_tables = $this->getTables(true);
}
$resolvedList = array();
foreach ($list as $entry) {
if (substr($entry, 0, 1) == '@') {
$code = substr($entry, 1);
if (!isset($definitions[$code])) {
throw new RuntimeException('Table-groups could not be resolved: ' . $entry);
}
if (!isset($resolved[$code])) {
$resolved[$code] = true;
$tables = $this->resolveTables(explode(' ', $definitions[$code]['tables']), $definitions, $resolved);
$resolvedList = array_merge($resolvedList, $tables);
}
continue;
}
// resolve wildcards
if (strpos($entry, '*') !== false) {
$connection = $this->getConnection();
$sth = $connection->prepare('SHOW TABLES LIKE :like', array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute(array(':like' => str_replace('*', '%', $this->dbSettings['prefix'] . $entry)));
$rows = $sth->fetchAll();
foreach ($rows as $row) {
$resolvedList[] = $row[0];
}
continue;
}
if (in_array($entry, $this->_tables)) {
$resolvedList[] = $this->dbSettings['prefix'] . $entry;
}
}
asort($resolvedList);
$resolvedList = array_unique($resolvedList);
return $resolvedList;
}