Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public function __set($name, $value) {
  2. if(in_array($name, self::$attributes[$this->className])) {
  3. $fieldMeta = self::$meta[$this->className][$name];
  4. $dbtype = $fieldMeta['dbtype'];
  5. if($dbtype != 'varchar') {
  6. switch($dbtype) {
  7. case 'int':
  8. if(empty($value)) {
  9. $value = null;
  10. }
  11. else {
  12. $value = (int)$value;
  13. }
  14. break;
  15.  
  16. case 'tinyint':
  17. $value = (bool)$value;
  18. break;
  19. }
  20. }
  21. }
  22. else if(!$this->isNewRecord() && isset($this->associations->{$name})) {
  23. $this->associations->save($name, $this, $value);
  24. }
  25.  
  26. $this->data[$name] = $value;
  27. }
Add Comment
Please, Sign In to add comment