/** * Gets mysql default value for a property * * Must be called only after $column's Null and Type has been set * * @param $property Reflection_Property * @param $column Column * @return mixed */ private static function propertyDefaultToMysql(Reflection_Property $property, Column $column) { $default = $property->getDeclaringClass()->getDefaultProperties()[$property->name]; if (isset($default)) { $property_type = $column->getType(); if ($property_type->isNumeric()) { $default = $default + 0; } elseif (is_array($default)) { $default = ''; } } else { if ($column->canBeNull()) { $default = null; } else { $property_type = $column->getType(); if ($property_type->isNumeric()) { $default = 0; } elseif ($property_type->isString() || $property_type->isMultipleString()) { $default = ''; } elseif ($property_type->isDateTime()) { $default = '0000-00-00 00:00:00'; } } } return $default; }