MySQL Varchar仅不记录interger


MySQL Varchar not recording interger only

$argUser-MySQL设置为VARCHAR(15)。

如果我寄信,一切都会好起来的
如果我寄字母和数字,一切都会好起来的
如果我只发布数字。。。它没有记录条目。。。

我使用的是CodeIgniter框架,这是我记录登录尝试的功能:

function testCredentials($row, $argUser) {
    $this->log_attempt = $argUser;
    $this->log_time = date("Y-m-d h:i:s");
    $this->log_ip = $_SERVER['REMOTE_ADDR'];
    if ($row->user_regid == $argUser) {
        $this->log_success = 'TRUE';
        $this->db->insert('logins', $this);
        return TRUE;
    } else {
        $this->log_success = 'FALSE';
        $this->db->insert('logins', $this);
        return FALSE;
    }
}

不要使用varchar来存储日期和时间。

您可以使用MySqldatetime数据类型来存储php日期(date("Y-m-d h:i:s");)