echo "Nebyla nalezena slozka app"; echo "\r\n"; echo "\r\n"; die; } checkPaths(); checkBases(); // Načtení názvu tabulek, $tables = array(); foreach ($db->query('SHOW TABLES')->fetchAll(PDO::FETCH_COLUMN) as $table) { $name = implode('', array_map(function ($word) { return ucfirst($word); }, explode('_', $table))); $cols = array(); foreach ($db->query("DESCRIBE `{$table}`") as $col) { $cols[$col['Field']] = '@property' . (strtolower($col['Extra']) == 'auto_increment' ? '-read' : NULL) . ' ' . getColType(strtolower($col['Type'])) . (strtolower($col['Null']) == 'yes' ? '|NULL' : NULL) . ' $' . $col['Field'] . "\n"; } $tables[$name] = array($table => $cols); } // Generování tříd, foreach ($tables as $className => $table) { foreach ($table as $name => $cols) { if (!file_exists(REPOSITORY_PATH . $className . '.php')) { //$entity_name = readline($className . ": "); $entity_name = readline_predefined($className . ": ", Inflector::singularize($className)); newEntity($cols, $entity_name); } else { $repository = file_get_contents(REPOSITORY_PATH . $className . '.php'); preg_match('/(?<=@entity \\\\).*/', $repository, $matches); if (!$matches) { continue;
function getTableCols($db, $table) { $cols = array(); foreach ($db->query("DESCRIBE `{$table}`") as $col) { $cols[$col['Field']] = '@property' . (strtolower($col['Extra']) == 'auto_increment' ? '-read' : NULL) . ' ' . getColType(strtolower($col['Type'])) . (strtolower($col['Null']) == 'yes' ? '|NULL' : NULL) . ' $' . $col['Field'] . "\n"; } return $cols; }