本文介紹了PHP/MySQLi:將 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:將 lc_time_names 和 DATE_FORMAT() 設置為 mysqli 查詢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!