Beispiel #1
0
<?php

/**
 * Created by PhpStorm.
 * User: leopelan
 * Date: 09/12/15
 * Time: 12:11
 */
require_once 'orm/Orm.php';
Orm::init('localhost', 'orm', 'root', 'root');
// var_dump(Orm::getAll('user'));
// var_dump(Orm::count('user'));
// Orm::deleteById('user','2');
Beispiel #2
0
<?php

require_once 'orm/Orm.php';
$Host = $argv[1];
$User = $argv[2];
$Password = $argv[3];
$dbName = $argv[4];
$tableName = $argv[5];
$className = ucfirst($argv[6]);
Orm::init($Host, $dbName, $User, $Password);
$fields = Orm::getColSql($tableName);
$tabs = 4;
function do_tabs($tabs)
{
    $ret = '';
    for ($i = 0; $i < $tabs; $i++) {
        $ret .= ' ';
    }
    return $ret;
}
$code = "<?php\n\n";
$code .= "class {$className}\n{\n";
$code .= do_tabs($tabs) . 'protected $tableNameBdd' . ";\n";
foreach ($fields as $field) {
    $code .= do_tabs($tabs) . 'protected $' . $field . ";\n";
}
$code .= "\n";
$code .= do_tabs($tabs) . 'public function set_tableNameBdd' . '($tableNameBdd' . ")\n";
$code .= do_tabs($tabs) . "{\n";
$code .= do_tabs($tabs + 2) . 'return $this->tableNameBdd' . ' = $tableNameBdd' . ";\n";
$code .= do_tabs($tabs) . "}\n";