| | |
| | | // | Author: Lukas Smith <smith@pooteeweet.org> |
|
| | | // +----------------------------------------------------------------------+
|
| | | //
|
| | | // $Id: Common.php,v 1.128 2007/11/09 20:54:58 quipo Exp $
|
| | | // $Id: Common.php,v 1.137 2008/02/17 18:53:40 afz Exp $ |
| | |
|
| | | require_once 'MDB2/LOB.php';
|
| | |
|
| | |
| | | $charset = empty($field['charset']) ? '' :
|
| | | ' '.$this->_getCharsetFieldDeclaration($field['charset']);
|
| | |
|
| | | $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; |
| | | $default = '';
|
| | | if (array_key_exists('default', $field)) {
|
| | | if ($field['default'] === '') {
|
| | |
| | | if (PEAR::isError($db)) {
|
| | | return $db;
|
| | | }
|
| | | if (empty($field['notnull'])) {
|
| | | $field['default'] = null;
|
| | | } else {
|
| | | $valid_default_values = $this->getValidTypes();
|
| | | $field['default'] = $valid_default_values[$field['type']];
|
| | | }
|
| | | if ($field['default'] === ''
|
| | | && ($db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)
|
| | | ) {
|
| | | if ($field['default'] === ''&& ($db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)) { |
| | | $field['default'] = ' ';
|
| | | }
|
| | | }
|
| | | if (!is_null($field['default'])) { |
| | | $default = ' DEFAULT '.$this->quote($field['default'], $field['type']);
|
| | | } elseif (empty($field['notnull'])) {
|
| | | $default = ' DEFAULT NULL';
|
| | | }
|
| | |
|
| | | $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
| | | } |
| | |
|
| | | $collation = empty($field['collation']) ? '' :
|
| | | ' '.$this->_getCollationFieldDeclaration($field['collation']);
|
| | | |
| | | return $charset.$default.$notnull.$collation;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | $value = (string)$value;
|
| | | $value = preg_replace('/[^\d\.,\-+eE]/', '', $value);
|
| | | if (preg_match('/[^.0-9]/', $value)) {
|
| | | if (preg_match('/[^\.\d]/', $value)) { |
| | | if (strpos($value, ',')) {
|
| | | // 1000,00
|
| | | if (!strpos($value, '.')) {
|