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

前端 未结 3 1688
一生所求
一生所求 2021-01-16 07:01

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\"), bi         


        
3条回答
  •  不思量自难忘°
    2021-01-16 07:08

    $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();
            }
    

提交回复
热议问题