PHP / MySQLi:SET lc_time_names和DATE_FORMAT()成一个mysqli查询? [英] PHP/MySQLi: SET lc_time_names and DATE_FORMAT() into a mysqli query?
本文介绍了PHP / MySQLi:SET lc_time_names和DATE_FORMAT()成一个mysqli查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下一个代码从数据库中的表中检索数据:
I use the next code to retrieve data from a table in the database:
$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'
到查询..
Like you can see, at the same time I format the date from the 'birthdate' column to a more friendly display using the DATE_FORMAT() MySQL function. Now, I want to display the month full names in Spanish, so I want to insert SET lc_time_names = 'es_ES'
into the query..
我如何做到?我可以添加 SET lc_time_names
到$ check_sql变量
How can I do it??? Can I add SET lc_time_names
to the $check_sql variable??
谢谢!!
推荐答案
$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和DATE_FORMAT()成一个mysqli查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文