I am running a LAMP server but now need to connect to MS SQL (client request). I have heard Microsoft has a driver, but can't verify if
Does anyone know if the Microsoft driver is available for Unix? If not, should I just stick with FreeTDS? This appears to be recommended by PHP, however install documentation seems lacking. Any direction on either would be greatly appreciated.
Sorry for the general question, I am not familiar with setting up PHP drivers.
UPDATE
Just for some back story, I am running an intranet from the LAMP server but needs to connect to a datasource on an external MS SQL DB Server (Windows of course). I am running PHP5.
FreeTDS is fine and works well enough. The Microsoft driver is Windows only, thus you wouldn't be able to use it on your Linux server.
First install FreeTDS and then configure PHP with --with-mssql=/prefix/used/for/freetds. If you are using your distribution's PHP, I'm sure there is a MS-SQL driver package already precompiled and available for installation (in Ubuntu, that'd be php5-sybase).
Then use PHP's mssql_* functions to actually do the work
For anyone who comes across this rather old question...
It should be noted that since 2010, Microsoft has actually developed a viable Linux driver for SQL Server that is installable via PECL. It's currently only compatible with PHP 7.
The main readme file is here, which lists some general and overly complicated installation instructions. But if you look at the latest release notes you will see that newer versions can be installed via PECL like so:
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
Related
Does anyone know if there is a PHP module for Sybase Active Server Edition (ASE), compatible with version 12.5 that will work with PHP 7+ since the removal of sybase_connect I'm struggling to find a driver and according to the documentation slqsrv needs MSSQL 2005+
I do have freeTDS installed, and have looked at PDO_DBLIB but it seems that it's not really coming recommended.
I'm running on Ubuntu Server LTS.
Plan B is it worth just trying to migrate my Script to something like Python -
please not Perl it screws with my head ;-)
THe ASE OpenClient SDK contains drivers for Perl, PHP and Python.You can get this either by downloading the full SDK from the SAP support website, but it may be easier to just download the ASE Express Edition from https://www.sap.com/community/topic/ase.html.
The connectivity drivers are located in $SYBASE/OCS_16-0.
My question is based off of this post's answer from #Crontab. I downloaded SQLSRV40 from Microsoft website. When I try to install it is asking for
When I install, I have to enter a path to extract files and as it mentions in the website under installation instructions No.3 "When prompted, enter the path to the PHP extensions directory".
I have xampp and there is a php file directory. For my extracting path should I just give 'C:/xampp/php'?
I am a bit confused because, the under the comment section in the answer, #Crontab mentioned "My guess would be wherever you find all the other php_*.dll files". This means all the php_*.dll files should be under php folder right?
Also, say, if I extract them into that folder or different folder, when I added php_pdo_sqlsrv_7_nts_x64 into my php.ini folder and connected via apache I could not find my pdo_sqlsrv dll.
This is my first time installing SQL server drive. Any suggestion would be appreciated.
Seeming like main issue was sqlsrv drivers available for download on Microsoft sites currently only support PHP 7.0.+, i.e. not PHP 7.1 or 7.2.
The solution is to either download newer drivers (https://github.com/Microsoft/msphpsql/releases support for 7.2 but labeled as "technical preview") or to downgrade to PHP version 7.0.
Other common gotchas are:
Failing to download the additional required Microsoft ODBC drivers.
Confusion over x86 and x64 versions of drivers (also ts/nts "thread safe" and "non thread safe"). Will depend on your system/php install.
Also seeing that pecl offers the 'preview' versions of the drivers: https://pecl.php.net/package/pdo_sqlsrv/5.0.0/windows
There they also offer up this useful description:
The Microsoft Drivers for PHP for SQL Server are PHP extensions that allow for the reading and writing of SQL Server data from within PHP scripts. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PDO for accessing data in all editions of SQL Server 2008 R2 and later (including Azure SQL DB). These drivers rely on the Microsoft ODBC Driver for SQL Server to handle the low-level communication with SQL Server.
I have installed the entire lamp stack with homebrew on my macbook pro. I am in need of getting the sybase module installed but am having the worst time trying to figure it out. I have done upteen google searches and read over the php.net section on sybase:
http://php.net/manual/en/sybase.installation.php
I have no clue when it says:
To enable Sybase-CT support configure PHP --with-sybase-ct[=DIR]
I was hoping to reach out to someone who has enabled/installed this on a mac or unix environment. Hope you can let me know the steps I need to run to get this up and running so I can use:
sybase_connect();
Thanks in advance.
You can also use FreeTDS to connect to Sybase from your Mac's PHP. Will be much easier than trying to configure the Sybase-CT library.
That section is asking for where on your system the Sybase installation is. To connect to a Sybase DB, you need to have either the client piece, SDK, or server piece installed on the local system.
The Sybase home directory includes the connection libraries that PHP is looking for.
I was having problems saving specific data using regular mssql_query as described here: How to correctly sanitize mssql query that stores emails
As you can see, some people recommended sqlsrv driver however it's not available for linux. What would be the best way to use mssql on linux then?
At present, Microsoft provides support for Linux Red Hat distribution Driver only. And it should be on 64 bit OS. http://www.microsoft.com/en-us/download/details.aspx?id=28160
And also its not a OpenSource application, its very difficult get support on Enterprise edition too. I better prefer to go on with MYSQL Database
As Marc B said, use PDO. You'll also want to use the FreeTDS driver. You'll need to: sudo apt-get install tdsodbc unixodbc php5-odbc.
You can see further configuration in this answer.
I'm trying to connect with Laravel 4 to an SQL Server database. I'm getting an error, but I think it's a PHP error, not a Laravel error. It says PDOException: could not find driver. I have the driver set to sqlsrv like another example in the database.php file. Like I said, I think this is a PHP error, not Laravel.
I'm on localhost on my Mac. Do I need to configure something in my php.ini file? I found another article that said I need to comment out a MySQL driver under PDO. I also couldn't find that line in my php.ini. But I need to connect to a MySQL database as well, anyway. What do I need to change in my php.ini file?
I found this line:
pdo_mysql.cache_size = 2000
But commenting it out did nothing even after restarting Apache.
The sqlsrv driver is a windows-only driver according to the PHP Manual (www.php.net/manual/en/sqlsrv.requirements.php). So you can't use that driver on Mac, Linux, Unix or any other operating system than the ones listed on that page.
I assume you are trying to connect to a remote SQL Server somewhere? If you're on Mac, then SQL Server wouldn't be running on your local machine, so I guess the first question is whether or not you have a SQL Server running somewhere.
Second, from the server that is running PHP, you would need to connect using either FreeTDS or ODBC with FreeTDS.
Since Laravel 4 uses PDO, you'll need to install FreeTDS and ODBC. Laravel 4 doesn't use the mssql PHP extension. It uses PDO, so mssql won't get you anywhere with Laravel 4.
If you're serving PHP from your Mac, I would say there are generally 4 different ways you could go:
The Easy, but costly way: Go to (www.macupdate.com/app/mac/23152/openlink-odbc-driver-for-sybase) and download and install OpenLink ODBC driver. This allows you to create new ODBC connections using the Sybase (MSSQL) driver on a XNIX machine. There's an installation walk-through here (wikis.openlinksw.com/dataspace/owiki/wiki/UdaWikiWeb/InstallSybaseExpressOSX). It comes with a 15 day trial, after which you would have to purchase it. As of this writing, it appears to cost somewhere in the range of $30 - $50 depending on the license you choose.
The harder, but free way: Follow http://blog.benjaminwalters.net/?p=10 (slightly outdated) to re-compile FreeTDS support into PHP on Mac (assuming you're using MAMP)
The far better, but also far more work way: Find a Virtual Machine Host software like VMWare Fusion and install a Linux server like Ubuntu 12.4. Make sure you install apache2 and PHP during the install process and then follow the steps here to get FreeTDS working on your new server machine.
Run PHP from the Windows Server that is running SQL Server
Milage will vary with each solution, and there is a learning curve in any case. I've been a PHP developer for a long time, and it took me days to figure out how to get connected to SQL Server for the first time from Linux. Thankfully, there are quite a few walkthroughs out there now, and FreeTDS has come a long way since that time.
Hope that helps. :)
I actually have this running on my setup. My best advice is to get on the Homebrew bus.
https://github.com/josegonzalez/homebrew-php is where you're going to want to look for installing PHP and related items. I don't remember exactly what I did but it wasn't particularly difficult.
First you'll need FreeTDS.
brew install freetds
Then, add Jose's formulas to your homebrew (instructions on the github page). After that,
brew install php5x --with-mssql
brew options php5x
if you need more extensions.
Based on Jon Watson's comment,
I've tried step 2, and it doesn't work. check my issue here https://github.com/laravel/laravel/issues/2180
Step 3 is broken link and I think it's the same with step 2.
I also tried linux ODBC driver for Laravel (there are 2, google it), both doesn't work too. Although my simple test php works in both DBLIB and ODBC (compiled using official microsoft odbc unix driver).
Step 4 definitely works, BUT you must use IIS for best stability.
That leaves step 1. OR,
Ditch Laravel4 and use good ol' AdoDB http://adodb.sourceforge.net/ which I've been using since 2006 and still working superbly (although not modern like Laravel) configure it using tutorial in http://docs.moodle.org/20/en/Installing_MSSQL_for_PHP
I wonder why they don't build sqlsrv driver for linux too....