我在将日期(类型:日期时间)插入数据库时遇到了一些困难。 无论我放在那里,它都会引发有关日期格式等的语法错误。有人可以帮我吗?
DB::insert('INSERT INTO hidden_authors (e_user = ? AND h_user = ? AND h_change_time = ?)', array($userBanId, $id, date(Y-m-d H:i:s) ));
我已经尝试使用 sql getdate() 但它也给我一个错误。
最佳答案
Error Because of missing
"
insidedate()
function.
将此更改为
date(Y-m-d H:i:s)
这个
date("Y-m-d H:i:s")
所以最终的Well Form代码应该是
DB::insert('INSERT INTO hidden_authors (e_user = ? AND h_user = ? AND h_change_time = ?)',array($userBanId, $id, date("Y-m-d H:i:s")));
Tip For Your Code:
Without add exact function in query, assign that to variable and call it to your query
示例:
$date = date("Y-m-d H:i:s");
所以里面查询
DB::insert('INSERT INTO hidden_authors (e_user = ? AND h_user = ? AND h_change_time = ?)',array($userBanId, $id, $date));
So when you read that
insert
function you can get clear idea about
- what you did?
- what you need to do?
- where is the error??
Its simply point all of these questions
关于php - 将日期时间插入数据库 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33102350/