Skip to content

Commit

Permalink
Values
Browse files Browse the repository at this point in the history
  • Loading branch information
EBethus committed Jun 13, 2016
1 parent 03a7927 commit 15a6fe5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 25 additions & 1 deletion lib/Kumbia/ActiveRecord/BaseRecord.php
Expand Up @@ -38,6 +38,13 @@ class BaseRecord
*/
protected static $pk = 'id';


/**
* Values of columns
* @var array
*/
protected $values = [];

/**
* Constructor.
*
Expand All @@ -48,6 +55,23 @@ public function __construct(array $data = [])
$this->dump($data);
}

public function __set($key, $value){
$this->values[$key] = $value;
}

public function __get($key){
return isset($this->values[$key]) ? $this->values[$key]: NULL;
}

/**
* Get the Primary Key value for the object
* @return mixed
*/
public function pk(){
$pk = static::getPK();
return $this->$pk;
}

/**
* Cargar datos al objeto.
*
Expand Down Expand Up @@ -84,7 +108,7 @@ protected function hasPK()
}

/**
* Obtiene la llave primaria.
* Get the name of the primary key
*
* @return string
*/
Expand Down
9 changes: 0 additions & 9 deletions lib/Kumbia/ActiveRecord/LiteRecord.php
Expand Up @@ -145,15 +145,6 @@ public function save(array $data = [])
return true;
}

/**
* Get the Primary Key value for the object
* @return mixed
*/
public function pk(){
$pk = static::getPK();
return empty($this->$pk) ? null : $this->$pk;
}

/**
* Retorna el nombre del metodo a llamar durante un save (create o update).
*
Expand Down

0 comments on commit 15a6fe5

Please sign in to comment.