Hi,
i have this simple Controller: namespace Controllers; class TypesController extends \Phalcon\Mvc\Controller {
public function indexAction() {
header('Content-Type: application/json; charset=utf-8');
$Types = new \Models\Types;
$response["count"] = $Types::count();
$fetch = $Types::find("active=1");
foreach ($fetch as $robot) {
$robot->name = utf8_encode($robot->name);
$response["fetch"][] = json_decode(json_encode($robot));
}
return $response;
}
}
My database collation is utf-8, in the database connection config I have set the UTF-8 parameter. How can i ensure that every column entry is utf-8 encoded, like $robot->name = utf8_encode($robot->name);. If I had to make that for every column my model would somehow be useless. Also, is there a better way to set the header?