作者:陈庭勇筱玲喜芳 | 来源:互联网 | 2023-09-06 17:29
ImstarintouseCarbontomanageDatesinPHPwithMySQL,butImhavingproblemswithasimpleIn
I'm starin to use Carbon to manage Dates in PHP with MySQL, but I'm having problems with a simple Insert statement. To run SQL statements I'm using Medoo, this is my code to insert:
我很想使用Carbon来管理带有MySQL的PHP中的Dates,但是我遇到了一个简单的Insert语句问题。要运行我正在使用Medoo的SQL语句,这是我要插入的代码:
public function register($code, $fullname, $address, $phones, $email, $now){
$registration = $this->_app['medoo']->insert("customers",[
'cus_code' => $code,
'cus_fullname' => $fullname,
'cus_address' => $address,
'cus_phone_s' => $phones,
'cus_email' => $email,
'created_at' => $now
]);
return $registration;
}
And this is where I pass the value:
这是我传递价值的地方:
$code = $request->get('code');
$name = $request->get('name');
$phOnes= $request->get('phone_s');
$address = $request->get('address');
$email = $request->get('email');
$now = Carbon::now('America/Monterrey');
$customer_registration = $app['customer.model']->register($code, $name, $address, $phones, $email, $now);`
if($customer_registration){
$request_status = true;
}else {
$request_errors[] = "Ocurrio un error al registrar el cliente";
}
The statement returns an error and this is the output if I debug it:
该语句返回一个错误,如果我调试它,这是输出:
INSERT INTO "customers"
("cus_code", "cus_fullname", "cus_address", "cus_phone_s", "cus_email", "created_at")
VALUES
('n20', 'notaria 20', 'lerdo 202', '1234567890', 'mail@mail.com')
As you can see, the date is missing and It doesn't make any sense because if I echo it inside my function...
正如你所看到的,日期缺失了,它没有任何意义,因为如果我在我的函数中回应它...
public function register($code, $fullname, $address, $phones, $email, $now){
echo 'this is the variable now: '.$now.'
';
$this->_app['medoo']->debug()->insert("customers",[
'cus_code' => $code,
'cus_fullname' => $fullname,
'cus_address' => $address,
'cus_phone_s' => $phones,
'cus_email' => $email,
'created_at' => $now
]);
die();
return $registration;
}
outputs...
this is the variable now: 2017-05-14 00:52:00
INSERT INTO "customers"
("cus_code", "cus_fullname", "cus_address", "cus_phone_s", "cus_email", "created_at")
VALUES
('n20', 'notaria20', 'lerdo 202', '1234567890', 'mail@mail.com')
I changed $now for Date('Y-m-d H:m:s') and It works, but for my app I need to use Carbon.
我现在为Date更改$('Y-m-d H:m:s')并且它有效,但对于我的应用程序,我需要使用Carbon。
I hope I was clear with this, I'm not so good with english, please help!
我希望我对此很清楚,我对英语不太满意,请帮忙!
1 个解决方案