My query executed in PDO (PHP, pgsql) using (LIKE) do not query the regists with (ñ,´), i triyed with this in HTML:
<meta charset="utf-8">
And this in PHP:
header("Content-Type: application/json; charset=UTF-8");
public static function connect(){
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
if (null == self::$cont) {
try {
self::$cont = new PDO("pgsql:host=" . self::$dbhost . " options='--
client_encoding=UTF8' ;port=" . self::$dbport
. "; dbname= " . self::$db, self::$dbuser, self::$dbpass . "", $options);
} catch (PDOException $e) {
die(" ERROR POR CONEXIÓN " . $e->getMessage());
}
}
return self::$cont;
}
$pdo = Database::connect();
$criterio = "%" . mb_strtoupper($filtro) . "%";
$sql = ' SELECT gui_id, gui_nombre, gui_especialidad, gui_telefono, gui_direccion
FROM guiaslocales
WHERE gui_nombre LIKE :criterio';
$q = $pdo->prepare($sql);
$q->bindParam(":criterio", $criterio, PDO::PARAM_STR);
$q->execute();
$resultado = $q->fetchAll(PDO::FETCH_ASSOC);
In Frontend (VueJS)
await this.axios
.post("guiaslocales.php?dato=getguias", JSON.stringify(parametros))
.then(function (response) {
if (response.status === 200) {
self.guias = response.data;
if (self.guias.length === 0) {
self.mensajeWar("No se encontraron guias con ese criterio de busqueda");
}
}
})
.catch((error) => {
this.global.catching(error);
})
.finally(() => {
self.cargaskeletonguias = false;
});
In PgAdmin work OK, but in PHP the SELECT LIKE that contains (ñ) or (´) returns empty