Benubird
Benubird

Reputation: 19477

Why is PDO working without dbname?

I am connecting to my database using this command:

$resource = new PDO('odbc:driver=FreeTDS;Server=127.0.0.1;Port=8090;UID=Reporting;PWD=readonly;');

There is no dbname specified, and yet, it still connects to a database. The problem is, it is connecting to the wrong database. I tried including a section dbname=DATABASENAME;, but this was entirely ignored. How do I tell PDO to connect to a different database?

Upvotes: 1

Views: 382

Answers (2)

leo wong
leo wong

Reputation: 95

did you try to do the Standard operation? like....

new PDO("odbc:Driver={SQL Server};Server=127.0.0.1;Database=test;",'sa','password'); 

and which database you are using? ms sql server or some else?

Upvotes: 0

Sal00m
Sal00m

Reputation: 2916

Use DATABASE instead of DBNAME, i think this is the problem:

$resource = new PDO('odbc:driver=FreeTDS;Server=127.0.0.1;Port=8090;DATABASE=DATABASENAME;UID=Reporting;PWD=readonly;');

Upvotes: 1

Related Questions