Example #1
0
 public static function objects(Model $model)
 {
     $object = new Objects();
     $object->model = $model;
     $object->tables[0] = $model->get_fullname();
     return $object;
 }
Example #2
0
 public function update(Model $model, $array, $update)
 {
     foreach ($array as $key => $value) {
         $colsn = explode(" = ", $value);
         $cols = explode("__", $colsn[0]);
         $object = $model;
         foreach ($cols as $col) {
             $const = $object->{"get" . ucfirst($col)}();
             if ($const instanceof Constrain) {
                 $refer = $const->getRefer();
                 Kernel::import($refer);
                 $class = $const->getReferModel();
                 $fulln = $const->getFullRefer();
                 $name = $const->name();
                 if ($object == $model) {
                     $this->where("{$col} = {$refer}.{$name}");
                 } else {
                     $this->join($object->get_fullname(), null, $fulln, null, "{$col} = {$refer}.{$name}");
                 }
                 $object = new $class();
             } else {
                 return false;
             }
         }
     }
     return $this->get_sql_update($model->get_fullname(), $update);
 }