示例#1
0
{
    $ret = "";
    for ($i = 0; $i < $tabs; $i++) {
        $ret .= "\t";
    }
    return $ret;
}
$host = $argv[1];
$user = $argv[2];
$password = $argv[3];
$db = $argv[4];
$tableName = $argv[5];
$className = $argv[6];
Orm::init($host, $db, $user, $password);
// Do some magic here
$fields = Orm::getTableColumns($tableName);
$tabs = 1;
$code = "<?php\n\n";
$code .= "namespace App\\Entity;\n\n";
$code .= "use App\\Orm\\QueryManager;\n\n";
$code .= "class {$className} extends QueryManager\n{\n";
$code .= do_tabs($tabs) . "/** PROPERTIES */\n";
$code .= do_tabs($tabs) . 'private $tableName = "' . $tableName . '";' . "\n";
foreach ($fields as $field) {
    if (strtolower($field) == 'id') {
        continue;
    }
    $code .= do_tabs($tabs) . 'private $' . $field . ";\n";
}
$code .= do_tabs($tabs) . 'private $isUnique = "' . Orm::getUniqueColumnName($tableName) . '";' . "\n";
$code .= "\n" . do_tabs($tabs) . "/** SETTER */\n";
示例#2
0
 public function getTableColumns($tablename)
 {
     return Orm::getTableColumns($tablename);
 }