php获取时间插入到数据库,将datetime插入数据库PHP

将date(type:datetime)插入数据库时​​遇到一些困难.

无论我放在那里,它都会引发关于日期格式的语法错误等.有人可以帮助我吗?

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 " inside date() 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,mysql,date,insert,laravel

来源: https://codeday.me/bug/20190717/1488827.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值