我使用下一个代码从数据库中的表中检索数据:
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模板网!
mysql 中的 store_result() 和 get_result() 返回 falsestore_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
调用未定义的函数 mysqli_result::num_rows()Call to undefined function mysqli_result::num_rows()(调用未定义的函数 mysqli_result::num_rows())
PHP 准备好的语句问题PHP Prepared Statement Problems(PHP 准备好的语句问题)
mysqli_fetch_array 只返回一个结果mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一个结果)
PHP MySQLi 多次插入PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
如何确保 MySQL 中的值在 PHP 中保持其类型?How do I make sure that values from MySQL keep their type in PHP?(如何确保 MySQL 中的值在 PHP 中保持其类型?)