Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
Problem with PDO WHERE when using VARCHAR-columns in SQL Server

We are upgrading our MS SQL Server from SQL Server 2012 to the current version. We are using PDO with M$ ODBC driver running on CentOS Linux. PHP version is 7.4.

The problem is that if there is a (prepared) condition like

WHERE variable = ? 

and variable is of type VARCHAR there comes an error

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The data types varchar and text are incompatible in the equal to operator

An example code is like this:

$stmt = $db->prepare("SELECT * FROM Users WHERE user_login = ? AND user_application  = ?");
$stmt->execute([$login, $app]);

user_login and user_application are both VARCHAR-columns and $login and $app normal PHP string variables.

It wasn't a problem with the previous SQL server, the comparison went OK. I don't want to go through all the codebase to circumvent this in myriads of places - so - is there some setting somewhere (SQL server, ODBC-driver, PHP config, ...) where to set things "right" again?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Seems, it was sort of privileges error after the database migration. I removed the user that had come from restore operation and granted correct privileges again. Only, I am quite positive, I had done it already once. And I think there was no login errors when trying to use the database.

Sorry for dumb question. Though, I have always said, that there are no dumb questions, just dumb askers...

hank

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda