Answer the question
In order to leave comments, you need to log in
Connect to mssql from macosx?
I'd like to be able to work with mssql.
The config
is on a machine with a database:
- Microsoft SQL Server 2000 Service Pack 4
- Microsoft Windows Server 2003 Service Pack 2 64x Standard Edition
On the client:
- MacOSX 10.8.4
- MAMP 2.1.1
What I have already tried:
- compile so for php yourself
- use macports to install pdo_dblib, pdo_odbc
- naturally installed freetds
What is the result:
- pdo_odbc says - "invalid data source name" - I connect like this - $ dbh = new PDO ("DRIVER = odbc; dbname = dbname; host = dbserver; port =1433;user='sa';password=1234");
- mssql_connect - "Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server..."
- pdo_dblib - "SQLSTATE[] (null) (severity 0)" - connect like this - $dbh = new PDO ("dblib:host=dbserver;dbname=dbname", "sa", "1234");
I tried to specify the port, and through: and through, nothing helps.
Moreover, everything works through tsql -H dbserver -p 1433 -U sa -P 1234 -D dbname ...
Naturally, php.ini has everything you need.
There is everything in freetds.conf, and it is put in the right places, also with odbc.ini
Tell me where to dig? The second day I suffer.
Answer the question
In order to leave comments, you need to log in
Everything worked out. Guided by the article . But besides everything, you need to do $ export ODBCSYSINI=/opt/local/etc
before using isql and add to envvars
ODBCINI="/opt/local/etc/odbc.ini"
export ODBCINI
ODBCSYSINI="/opt/local/etc"
export ODBCSYSINI
- MAMP 2.1.1
Everything is not easy there, and you also have a version of the SQL server older than dinosaurs.
I connected to Linux via PDO with the line
odbc:Driver={SQL Server Native Client 11.0};Server='.$host.';Database='.$database.';CharacterSet=UTF-8
But before that, the admin puffed very significantly (patched something there) to make it start.
Well, if you suddenly need to work with text other than Latin, and even in a field with the nvarchar type, then you are guaranteed nights of unbridled sex :)
Now I'm trying, I was just guided by the article http://blog.benjaminwalters.net/?p=10 , and I wanted a simpler solution, but as it turned out, everything is not so simple.
We work with mssql via freetds.schemamania.org/
It's convenient for me.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question