Пример #1
0
 /**
  * @param mixed $instance
  */
 public function save($instance)
 {
     $array = BinderObject::toArrayFrom($instance, true);
     $query = new Query();
     $query->table($this->mapper->getTable())->fields(array_keys($array));
     if (empty($array[$this->mapper->getPrimaryKey()]) || count($this->get($array[$this->mapper->getPrimaryKey()])) === 0) {
         $array[$this->mapper->getPrimaryKey()] = $this->insert($query, $array);
         BinderObject::bindObject($array, $instance);
     } else {
         $this->update($query, $array);
     }
 }
Пример #2
0
 /**
  * Bind the properties from a source object to the properties matching to a target object
  *
  * @param mixed $source
  * @param mixed $target
  */
 public static function bindObject($source, $target)
 {
     $binderObject = new BinderObject();
     $binderObject->bindObjectInternal($source, $target);
 }