Exemple #1
0
 /**
  * Set model properties within the changed data array,
  * so that they can be saved later.
  *
  * @param string $key   The property to set
  * @param mixed  $value The value to set
  *
  * @return mixed The new value
  */
 public function __set($key, $value)
 {
     // Check that the field being updated is an actual database field
     if ($this->table->hasField($key)) {
         // Remember the old value
         $this->originalData[$key] = $this->data[$key];
     }
     return $this->data[$key] = $value;
 }
Exemple #2
0
 /**
  * Changes query type to delete, then executes the query.
  *
  * @param array $fields The fields to be deleted
  *
  * @return bool
  */
 public function delete()
 {
     $this->type = self::DELETE;
     // We can't use aliases for columns in a delete query,
     // so we reset the table name here to avoid errors,
     // and re-store it in the cache.
     $this->table = Table::find($this->table->name, $this->table->name, $this->instance);
     return $this->execute();
 }