How do I insert a date into mysql as a parameter?

后端 未结 2 1789
既然无缘
既然无缘 2021-01-21 18:38

I have the following code:

function dbInsert()
{
    global $dbcon, $dbtable;
    global $inputData;

    $sqlQuery = \'INSERT INTO \' . $dbtable . \' (id_author         


        
2条回答
  •  借酒劲吻你
    2021-01-21 19:19

    You could take a look at the STR_TO_DATE function. It takes a format parameter. The allowed values for the format parameter are described here.

    $sqlQuery = 'INSERT INTO ' . $dbtable . ' (id_author, date, title, description)' .
                ' VALUES (?, STR_TO_DATE(?, \'%d.%m.%Y\'), ?, ?)';
    

提交回复
热议问题