我有一个插入表格的数组:
$leadValues = array();
$leadValues[ 'LEADCOMM' ] = getVariable('LEADCOMM');
$leadValues[ 'CCID' ] = getVariable('CCID');
$leadValues[ 'QTR' ] = getVariable('QTR');
$leadValues[ 'CLK' ] = getVariable('CLK');
$leadValues[ 'DCK' ] = getVariable('DCK');
$leadValues[ 'QS_PRODUCT' ] = getVariable('QS_PRODUCT');
$leadValues[ 'PROP_ST' ] = getVariable('PROP_ST');
$leadValues[ 'QS_PROP_DESC' ] = getVariable('QS_PROP_DESC');
$leadValues[ 'QS_CRED_GRADE' ] = getVariable('QS_CRED_GRADE');
$leadValues[ 'EST_VAL' ] = getVariable('EST_VAL');
$leadValues[ 'BAL_ONE' ] = getVariable('BAL_ONE');
$leadValues[ 'QS_FHA_BANK_FORECLOSURE' ] = getVariable('QS_FHA_BANK_FORECLOSURE');
$leadValues[ 'QS_VA_STATUS' ] = getVariable('QS_VA_STATUS');
$leadValues[ 'FNAME' ] = getVariable('FNAME');
$leadValues[ 'LNAME' ] = getVariable('LNAME');
$leadValues[ 'ADDRESS' ] = getVariable('ADDRESS');
$leadValues[ 'CITY' ] = getVariable('CITY');
$leadValues[ 'PROP_ZIP' ] = getVariable('PROP_ZIP');
$leadValues[ 'EMAIL' ] = getVariable('EMAIL');
$leadValues[ 'PRI_PHONE_1' ] = getVariable('PRI_PHONE_1');
$leadValues[ 'PRI_PHONE_2' ] = getVariable('PRI_PHONE_2');
$leadValues[ 'PRI_PHONE_3' ] = getVariable('PRI_PHONE_3');
$leadValues[ 'PPCID '] = getVariable('PPCID');
$leadValues[ 'CID' ] = getVariable('CID');
我想将最后一项添加到数组中,该数组将在表中插入时间戳。这样的事情会起作用吗?
$leadValues[ 'TS' ] = $date->format( 'd/m/Y H:i:s' );
答案 0 :(得分:1)
你可以使用time()函数。它返回当前的unix时间戳
$leadValues[ 'TS' ] = time();
答案 1 :(得分:0)
理想情况下,您要将'timestamp'字段的表修改为TIMESTAMP数据类型。它将自己进行自动初始化和更新,从而远离PHP。
请参阅http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html