Fix utf8 and JSON issues resulting from MYSQL being weird
This commit is contained in:
parent
07c1a90845
commit
d1612e2804
|
@ -28,7 +28,7 @@ class Doors{
|
|||
}
|
||||
|
||||
public function getByName($name){
|
||||
$query = 'SELECT * FROM doors WHERE name=:name';
|
||||
$query = 'SELECT name, open, description FROM doors WHERE name=:name';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
|
|
@ -35,4 +35,15 @@ elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
}
|
||||
}
|
||||
|
||||
echo json_encode($out);
|
||||
function utf8ize($d) {
|
||||
if (is_array($d)) {
|
||||
foreach ($d as $k => $v) {
|
||||
$d[$k] = utf8ize($v);
|
||||
}
|
||||
} else if (is_string ($d)) {
|
||||
return utf8_encode($d);
|
||||
}
|
||||
return $d;
|
||||
}
|
||||
|
||||
echo json_encode(utf8ize($out));
|
||||
|
|
Loading…
Reference in New Issue