Exemplo n.º 1
0
 /**
  *	@short Loads the child the receiver in a one-to-one relationship.
  *	@param table_name The name of the child table.
  *	@param params An array of conditions. For the semantics, see find_all
  *	@see find_all
  */
 public function has_one($table_name)
 {
     $childclass = table_name_to_class_name($table_name);
     $obj = eval("return new {$childclass}();");
     $fkey = $this->get_foreign_key_name();
     $children = $obj->find_all(array('where_clause' => "`{$fkey}` = {$this->values[$this->primary_key]}", 'limit' => 1));
     if (count($children) > 0) {
         $child = $children[0];
         $child->values[singularize($this->table_name)] = $this;
         $this->values[singularize($table_name)] = $child;
     }
 }
Exemplo n.º 2
0
<?php

require_once dirname(__FILE__) . "/../include/common.inc.php";
if (count($argv) > 2) {
    if ($argv[1] == 'controller') {
        $controller = $argv[2];
        echo "\tcreating controllers/{$controller}_controller.php\n";
        $controller_class = table_name_to_class_name("{$controller}_controller");
        $controller_code = <<<EOT
<?php
\trequire_once(dirname(__FILE__) . "/base_controller.php");
\t
\tclass {$controller_class} extends BaseController
\t{
EOT;
        for ($i = 3; $i < count($argv); $i++) {
            echo "\tcreating views/{$controller}/{$argv[$i]}.php\n";
            mkdir(dirname(__FILE__) . "/../views/{$controller}", 755);
            file_put_contents(dirname(__FILE__) . "/../views/{$controller}/{$argv[$i]}.php", "");
            $controller_code .= <<<EOT
\t\t\t
\t\tfunction {$argv[$i]}()
\t\t{
\t\t}

EOT;
        }
        $controller_code .= <<<EOT

\t}
?>