diff options
Diffstat (limited to 'easyCRUD/easyCRUD.class.php')
-rw-r--r-- | easyCRUD/easyCRUD.class.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/easyCRUD/easyCRUD.class.php b/easyCRUD/easyCRUD.class.php index f369197..d6e6bff 100644 --- a/easyCRUD/easyCRUD.class.php +++ b/easyCRUD/easyCRUD.class.php @@ -12,16 +12,28 @@ class Crud { public $variables; + public function __construct($data = array()) { + $this->db = new DB(); + $this->variables = $data; + } + public function __set($name,$value){ - $this->variables[$name] = $value; + if(strtolower($name) === $this->pk) { + $this->variables[$this->pk] = $value; + } + else { + $this->variables[$name] = $value; + } } public function __get($name) { - if(array_key_exists($name,$this->variables)) { - return $this->variables[$name]; + if(is_array($this->variables)) { + if(array_key_exists($name,$this->variables)) { + return $this->variables[$name]; + } } - + $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . @@ -31,11 +43,6 @@ class Crud { return null; } - public function __construct($data = array()) { - $this->db = new DB(); - $this->variables = $data; - } - public function save($id = "0") { $this->variables[$this->pk] = (empty($this->variables[$this->pk])) ? $id : $this->variables[$this->pk]; |