Changeset 9947
- Timestamp:
- 11/17/08 03:39:00 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.8/jaws/html/libraries/pear/MDB2/Schema.php
r8054 r9947 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: Schema.php,v 1.12 3 2008/03/24 19:12:32ifeghali Exp $46 // $Id: Schema.php,v 1.127 2008/11/17 00:11:13 ifeghali Exp $ 47 47 // 48 48 … … 421 421 'create' => true, 422 422 'overwrite' => false, 423 'charset' => ' ',423 'charset' => 'utf8', 424 424 'description' => '', 425 425 'comments' => '', … … 1282 1282 1283 1283 $dbOptions = array(); 1284 if (isset($database_definition['charset'])) { 1284 if (array_key_exists('charset', $database_definition) 1285 && !empty($database_definition['charset'])) { 1285 1286 $dbOptions['charset'] = $database_definition['charset']; 1286 1287 } … … 1403 1404 foreach ($previous_definition['tables'] as $table_name => $table) { 1404 1405 if (empty($defined_tables[$table_name])) { 1405 $changes[' remove'][$table_name] = true;1406 $changes['tables']['remove'][$table_name] = true; 1406 1407 } 1407 1408 } … … 1431 1432 foreach ($previous_definition['sequences'] as $sequence_name => $sequence) { 1432 1433 if (empty($defined_sequences[$sequence_name])) { 1433 $changes[' remove'][$sequence_name] = true;1434 $changes['sequences']['remove'][$sequence_name] = true; 1434 1435 } 1435 1436 } … … 1483 1484 } 1484 1485 if (!empty($change)) { 1486 if (array_key_exists('default', $change) 1487 && $change['default'] 1488 && !array_key_exists('default', $field)) { 1489 $field['default'] = NULL; 1490 } 1485 1491 $change['definition'] = $field; 1486 1492 $changes['change'][$field_name] = $change; … … 1864 1870 foreach ($changes['change'] as $index_name => $index) { 1865 1871 if (!empty($index['primary']) || !empty($index['unique'])) { 1872 $this->db->expectError(MDB2_ERROR_NOT_FOUND); 1873 $result = $this->db->manager->dropIndex($table_name, $index_name); 1874 $this->db->popExpect(); 1875 if (PEAR::isError($result) && !MDB2::isError($result, MDB2_ERROR_NOT_FOUND)) { 1876 return $result; 1877 } 1866 1878 $this->db->expectError(MDB2_ERROR_NOT_FOUND); 1867 1879 $result = $this->db->manager->dropConstraint($table_name, $index_name, !empty($index['primary'])); branches/0.8/jaws/html/libraries/pear/MDB2/Schema/Validate.php
r7547 r9947 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: Validate.php,v 1. 38 2008/02/06 23:13:51ifeghali Exp $46 // $Id: Validate.php,v 1.40 2008/11/15 23:53:47 ifeghali Exp $ 47 47 // 48 48 … … 204 204 foreach ($table['fields'] as $field_name => $field) { 205 205 if (!empty($field['autoincrement'])) { 206 if ($ primary) {206 if ($autoinc) { 207 207 return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, 208 208 'there was already an autoincrement field in "'.$table_name.'" before "'.$field_name.'"'); 209 209 } 210 $autoinc = $ primary = true;210 $autoinc = $field_name; 211 211 } 212 212 } … … 227 227 * a primary key index. 228 228 */ 229 if ($autoinc && count($index['fields']) == '1') { 229 if (count($index['fields']) == '1' 230 && array_key_exists($autoinc, $index['fields'])) { 230 231 $skip_index = true; 231 } elseif ($ primary) {232 } elseif ($autoinc || $primary) { 232 233 return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, 233 234 'there was already an primary index or autoincrement field in "'.$table_name.'" before "'.$name.'"'); … … 873 874 case 'timestamp': 874 875 if (!preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $field_value) 876 && strcasecmp($field_value, 'now()') != 0 875 877 && $field_value !== 'CURRENT_TIMESTAMP' 876 878 ) {
