column with accentuation invalid [closed]

0

I am putting together a report using a system database and PHP with DBLIB, but whoever structured the database created the tables and fields with accentuation. When I'm going to do a query in some field that does not have accent the query works, but when accent has invalid column error.

Example:

 select CAST(cp.[vencimento] AS date) as vencimento from contaspagar as cp;  //essa funciona de boa
 select CAST(cp.[dataemissão] AS date) as dataemissao from contaspagar as cp; //essa da erro de coluna invalida

I'm using Linux, PHP 5.6, and the freetds library to connect in SQL, SQL 2008 express.

Error in PHP:

  

SQLSTATE [HY000]: General error: 207 General SQL Server error: Check messages from the SQL Server [207] (severity 16) [(null)] NULL

Meaning of the error:

  

Invalid column name '%. * ls'.

    
asked by anonymous 26.01.2017 / 19:31

2 answers

2

When the names of the identifiers (columns tables ect) have accented characters or other types use escapes, in the case of SQL SERVER are brackets ( [] )

Change:

SELECT descrição FROM ...

To:

SELECT [descrição] FROM ...
    
26.01.2017 / 19:34
2

Solution:

$query=iconv( 'UTF-8', 'Windows-1252', $query );

The connection to the DBMS is not UTF-8. FreeTDS is Ansi / Windows 1252.

    
27.01.2017 / 16:03