gpt4 book ai didi

PHP/MySQLi : SET lc_time_names and DATE_FORMAT() into a mysqli query?

转载 作者:搜寻专家 更新时间:2023-10-30 22:05:18 24 4
gpt4 key购买 nike

我使用下一个代码从数据库中的表中检索数据:

$check_sql = 'SELECT personID, name, DATE_FORMAT(persons.birthdate, "%d de %M, %Y"), birthplace, countryID FROM persons WHERE personID = ?';
if ($stmt->prepare($check_sql)) {
$stmt->bind_param('i', $pid);
$stmt->bind_result($personDB, $name, $birthdate, $birthplace, $countryID);
$stmt->execute();
$stmt->fetch();
}

如您所见,同时我使用 DATE_FORMAT() MySQL 函数将“生日”列中的日期格式化为更友好的显示。现在,我想用西类牙语显示月份全名,所以我想在查询中插入 SET lc_time_names = 'es_ES'..

我该怎么做???我可以将 SET lc_time_names 添加到 $check_sql 变量吗??

谢谢!!

最佳答案

$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query("SET lc_time_names = 'es_ES'");
$check_sql = 'SELECT personID, name, DATE_FORMAT(persons.birthdate, "%d de %M, %Y"), birthplace, countryID FROM persons WHERE personID = ?';
if ($stmt = $mysqli->prepare($check_sql)) {
$stmt->bind_param('i', $pid);
$stmt->bind_result($personDB, $name, $birthdate, $birthplace, $countryID);
$stmt->execute();
$stmt->fetch();
}

关于PHP/MySQLi : SET lc_time_names and DATE_FORMAT() into a mysqli query?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/769060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com