problem changing a TIMESTAMP to DEFAULT 0
This commit is contained in:
@@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2006-12-12 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
|
* libraries/Table.class.php: problem changing a TIMESTAMP to DEFAULT 0
|
||||||
|
|
||||||
2006-12-07 Marc Delisle <lem9@users.sourceforge.net>
|
2006-12-07 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* libraries/ip_allow_deny.lib.php: checks that the header contains
|
* libraries/ip_allow_deny.lib.php: checks that the header contains
|
||||||
only one IP address, thanks to Christian Schmidt
|
only one IP address, thanks to Christian Schmidt
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
// vim: expandtab sw=4 ts=4 sts=4:
|
||||||
|
|
||||||
class PMA_Table {
|
class PMA_Table {
|
||||||
|
|
||||||
@@ -268,6 +269,8 @@ class PMA_Table {
|
|||||||
&$field_primary, $index, $default_orig = false)
|
&$field_primary, $index, $default_orig = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$is_timestamp = strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1;
|
||||||
|
|
||||||
// $default_current_timestamp has priority over $default
|
// $default_current_timestamp has priority over $default
|
||||||
// TODO: on the interface, some js to clear the default value
|
// TODO: on the interface, some js to clear the default value
|
||||||
// when the default current_timestamp is checked
|
// when the default current_timestamp is checked
|
||||||
@@ -298,8 +301,7 @@ class PMA_Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($default_current_timestamp
|
if ($default_current_timestamp && $is_timestamp) {
|
||||||
&& strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1) {
|
|
||||||
$query .= ' DEFAULT CURRENT_TIMESTAMP';
|
$query .= ' DEFAULT CURRENT_TIMESTAMP';
|
||||||
// auto_increment field cannot have a default value
|
// auto_increment field cannot have a default value
|
||||||
} elseif ($extra !== 'AUTO_INCREMENT'
|
} elseif ($extra !== 'AUTO_INCREMENT'
|
||||||
@@ -308,10 +310,16 @@ class PMA_Table {
|
|||||||
$query .= ' DEFAULT NULL';
|
$query .= ' DEFAULT NULL';
|
||||||
} else {
|
} else {
|
||||||
if (strlen($default)) {
|
if (strlen($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) . '\'';
|
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($extra)) {
|
if (!empty($extra)) {
|
||||||
$query .= ' ' . $extra;
|
$query .= ' ' . $extra;
|
||||||
|
Reference in New Issue
Block a user