pq = $pq; } function __invoke(array $args = null) { $tables = $this->pq->exec("SELECT tablename FROM pg_tables WHERE schemaname='public'"); /* @var $tables \pq\Result */ foreach ($tables->fetchAllCols("tablename") as $table) { $this->genModel($table); } } function genModel($entity) { $title = ucwords($entity); $single = substr($title, -3) == "ies" ? substr($title, 0, -3)."y" : rtrim($title, "s"); $this->genTable($entity, $title, $single."Collection"); $this->genRowset($single."Collection", $single); $this->genRow($single); } function genTable($name, $class, $collection) { $ns = explode("\\", $class); if (count($ns) > 1) { $class = array_pop($ns); $dir = implode("/", $ns); $ns = "\\".implode("\\", $ns); } else { $ns = ""; $dir = ""; } $file = __DIR__."/../Model/$dir/$class.php"; if (!file_exists($file)) { file_put_contents($file, << 1) { $class = array_pop($ns); $dir = implode("/", $ns); $ns = "\\".implode("\\", $ns); } else { $ns = ""; $dir = ""; } $file = __DIR__."/../Model/$dir/$class.php"; if (!file_exists($file)) { file_put_contents($file, << 1) { $class = array_pop($ns); $dir = implode("/", $ns); $ns = "\\".implode("\\", $ns); } else { $ns = ""; $dir = ""; } $file = __DIR__."/../Model/$dir/$class.php"; if (!file_exists($file)) { file_put_contents($file, <<