コード例 #1
0
 public function get()
 {
     $obj = new static();
     foreach ($_GET as $key => $value) {
         $obj->{$key} = $value;
     }
     $db = DB::instance();
     $db->getObject($obj);
     if ($obj->reference['one']) {
         foreach ($obj->reference['one'] as $key => $val) {
             $modelName = "\\Model\\" . $val;
             $obj->{$key} = new $modelName();
             $obj->{strtolower($val)} = $obj->{$key};
             unset($obj->{$key});
             $db->getObject($obj->{strtolower($val)});
         }
     } elseif ($obj->reference['many']) {
         foreach ($obj->reference['many'] as $key => $val) {
             $modelName = "\\Model\\" . $val;
             $obj->{$key} = new $modelName();
             $obj->{$key} = $obj->{$key}->getAll();
             $db->getAll($obj->{$key});
         }
     } elseif ($obj->reference['manytomany']) {
         foreach ($obj->reference['manytomany'] as $key => $val) {
             $modelName = "\\Model\\" . $val;
             $obj->{$key} = new $modelName();
             $tableMy = $this->getTable();
             $tableSecond = $obj->{$key}->getTable();
             $dbProc = DBProc::instance();
             $innerTable = "{$tableMy}_has_{$tableSecond}";
             $array = $dbProc->send_query("");
         }
     }
     return $obj;
 }
コード例 #2
0
ファイル: DB.php プロジェクト: AndriiPopovych/vstuprating
 public function updateObject(iDBable &$object)
 {
     $table = $object->getTable();
     $array = [];
     foreach ($object as $key => $val) {
         if ($val) {
             $array[$key] = $val;
         }
     }
     try {
         parent::update($table, $array, [$object->getPK() => $object->{$object->getPK()}]);
         return true;
     } catch (\Exception $e) {
         //echo $e->getMessage();
         return false;
     }
 }