I have to work with somebody's database for a game which sadly has a table named "User" or [dbo][User] and this can not be renamed. Now, I need to access this using PDO in PHP and when I use this query:
$query = "SELECT UserId AS INTUSERID FROM dbo.User WHERE YahooId = 'abcdef'";
it fails, as in nothing is fetched since "User" is a reserved keyword there. From the MS SQL Server I can do this as:
SELECT UserId AS INTUSERID FROM [GameName].[dbo].[User] WHERE YahooId = 'abcdef'
and it works. How should I prepare my query in PHP to make this execute? I have tried to put single quotes around table name but that has no effect. What is the correct way to use
[GameName].[dbo].[User]
from PHP PDO as the table name ?
Update: This is how I am connecting:
try{
$conn = new PDO("xxx.rds.amazonaws.com,1150;Database=xyz","admin","password");
} catch(PDOException $e){
echo "Connection failed: " . $e->getMessage();
}