0

I'm not an PHP expert but I'm trying to learn more. Here in my company I have a "Work Order" system based on PHP + MySQL. It works just fine but now I need to convert it to use MSSQL database. I did a lot of things and now almost all functions are working fine on MSSQL. But I have one function that I cannot figure out how to convert. That is:

public function check_username_1($username) {
  $data = $this->_db->select("SELECT tclients.Username FROM tclients WHERE tclients.Username = :username LIMIT 1", array(':username' => $username));
  return count($data);
}

If I use this function on MSSQL I get the error:

SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near 'LIMIT'.

I did some research here and found out that MSSQL doesn't suport LIMIT. Is there something I could replace it with?

Vlad
  • 18,195
  • 4
  • 41
  • 71

1 Answers1

0

The shortest path is to simply change the select to conform to MSSQL Syntax: the MSSQL equivalent for the LIMIT 1 clause is to say SELECT TOP 1

Curt
  • 5,518
  • 1
  • 21
  • 35