在表中插入数据时如何添加currentdatetime

uubf1zoe  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(327)

我在使用php 5.3版的脚本错误日志iam中发现了这些错误,下面是我的代码:

// add entry
                $sql  = "INSERT INTO plugin_reward_ppd_detail (reward_user_id, download_ip, file_id, download_country_group_id, download_date, reward_amount, status)
                    VALUES (:reward_user_id, :download_ip, :file_id, :download_country_group_id, :download_date, :reward_amount, 'pending')";
                $vals = array('reward_user_id'            => $file->userId,
                    'download_ip'               => $usersIp,
                    'file_id'                   => $file->id,
                    'download_country_group_id' => $countryGroupId,
                  **'download_date'             => sqlDateTime(),**
                    'reward_amount'             => $rewardAmount);
                $db->query($sql, $vals);
            }

我在这个问题上有个错误:
'下载日期'=>sqldatetime()

93ze6v8z

93ze6v8z1#

如果你想在“下载日期”列中添加当前时间,你可以试试这个

use DATE(''YYYY-MM-DD HH:MM:SS');
        $vals = array('reward_user_id'            => $file->userId,
                'download_ip'               => $usersIp,
                'file_id'                   => $file->id,
                'download_country_group_id' => $countryGroupId,
                'download_date'             =>DATE('YYYY-MM-DD HH:MM:SS'),
                'reward_amount'             => $rewardAmount);
            $db->query($sql, $vals);
        }

或者

other wise set download_date MySQL data-type: TIMESTAMP –
    Defulat value select :  CURRENT_TIMESTAMP   
     This an advanced version of DATETIME datatype. It has the same format as before. Unlike DATETIME, TIMESTAMP stores the current date and time on the creation of the table and on every update automatically. You do
     not need to change its value every time

相关问题