public function onInsert() { if (self::isUndef($this->getMark())) { $this->mark = null; } parent::onInsert(); }
private static function allSqlPropertiesNotUndef($instance) { $properties = get_class_vars(get_class($instance)); foreach ($properties as $name => $value) { if (BaseObject::isSqlPropertyMapping($name)) { if ($instance->isUndef($value)) { return false; } } } return true; }
public function testIsSqlPropertyMapping() { $this->given($res = \website\db\BaseObject::isSqlPropertyMapping('toto'))->then->boolean($res)->isTrue(); $this->given($res = \website\db\BaseObject::isSqlPropertyMapping('_toto'))->then->boolean($res)->isFalse(); $this->given($res = \website\db\BaseObject::isSqlPropertyMapping('Toto'))->then->boolean($res)->isFalse(); //snake case support $this->given($res = \website\db\BaseObject::isSqlPropertyMapping('toto_et_tata'))->then->boolean($res)->isTrue(); //camel case support $this->given($res = \website\db\BaseObject::isSqlPropertyMapping('totoEtTata'))->then->boolean($res)->isTrue(); }