problem changing a TIMESTAMP to DEFAULT 0
This commit is contained in:
@@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog
|
||||
$Id$
|
||||
$HeadURL$
|
||||
|
||||
2006-12-12 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* libraries/Table.class.php: problem changing a TIMESTAMP to DEFAULT 0
|
||||
|
||||
2006-12-11 Michal Čihař <michal@cihar.com>
|
||||
* lang/czech: Updated.
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
/* $Id$ */
|
||||
// vim: expandtab sw=4 ts=4 sts=4:
|
||||
|
||||
class PMA_Table {
|
||||
|
||||
@@ -269,6 +270,8 @@ class PMA_Table {
|
||||
&$field_primary, $index, $default_orig = false)
|
||||
{
|
||||
|
||||
$is_timestamp = strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1;
|
||||
|
||||
// $default_current_timestamp has priority over $default
|
||||
|
||||
/**
|
||||
@@ -299,8 +302,7 @@ class PMA_Table {
|
||||
}
|
||||
}
|
||||
|
||||
if ($default_current_timestamp
|
||||
&& strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1) {
|
||||
if ($default_current_timestamp && $is_timestamp) {
|
||||
$query .= ' DEFAULT CURRENT_TIMESTAMP';
|
||||
// auto_increment field cannot have a default value
|
||||
} elseif ($extra !== 'AUTO_INCREMENT'
|
||||
@@ -309,7 +311,13 @@ class PMA_Table {
|
||||
$query .= ' DEFAULT NULL';
|
||||
} else {
|
||||
if (strlen($default)) {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
|
||||
if ($is_timestamp) {
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT ' . PMA_sqlAddslashes($default);
|
||||
} else {
|
||||
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user