[eluser]Sinclair[/eluser]
Hi, I have tested this query in my SQL client and works, but when I do this query in CodeIgniter I got errors. Oh the database is PostgreSQL.
The query in model is:
Quote:select
a.id_anuncio, a.n_anuncio, a.id_foto_anuncio,
fa.n_ficheiro
from
aa_tags t JOIN aa_anuncios a ON t.id_anuncio = a.id_anuncio
JOIN aa_anuncios_anunciantes aa ON a.id_anuncio = aa.id_anuncio
JOIN ae_anunciantes ae ON aa.id_anunciante = ae.id_anunciante
JOIN ap_pag_anuncios pa ON a.id_anuncio = pa.id_anuncio
JOIN aa_fotos_anuncios fa ON fa.id_anuncio = a.id_anuncio and
fa.id_foto = a.id_foto_anuncio
where
lower(translate(t.n_tag, '()!$?: ,&+-/.ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'
,
'-------------SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy') )
= lower(translate('". pg_escape_string($pn_tag) ."', '()!$?: ,&+-/.ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'
,
'-------------SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy')) and
pa.dat_inicio <= NOW() and
(pa.dat_fim >= NOW() or pa.dat_fim is NULL)
The errors I got are:
Code:
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\acomp_www\system\application\controllers\tag.php:55)
Filename: codeigniter/Common.php
Line Number: 360
Code:
A Database Error Occurred
Error Number:
ERROR: invalid byte sequence for encoding "UTF8": 0x8a HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
select a.id_anuncio, a.n_anuncio, a.id_foto_anuncio, fa.n_ficheiro from aa_tags t JOIN aa_anuncios a ON t.id_anuncio = a.id_anuncio JOIN aa_anuncios_anunciantes aa ON a.id_anuncio = aa.id_anuncio JOIN ae_anunciantes ae ON aa.id_anunciante = ae.id_anunciante JOIN ap_pag_anuncios pa ON a.id_anuncio = pa.id_anuncio JOIN aa_fotos_anuncios fa ON fa.id_anuncio = a.id_anuncio and fa.id_foto = a.id_foto_anuncio where lower(translate(t.n_tag, '()!$?: ,&+-/.ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ', '-------------SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy')) = lower(translate('acompanhante-lisboa', '()!$?: ,&+-/.ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ', '-------------SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy')) and pa.dat_inicio <= NOW() and (pa.dat_fim >= NOW() or pa.dat_fim is NULL)
There are other ways of doing this?
I'am able to user the similar TRANSLATE function in php(strtr) inside the SQL code?
Similar function written in PHP:
Code:
$pn_tag=strtr($pn_tag,
"()!$?: ,&+-/.ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"-------------SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
If yes, how to?
Best Regards