Laravel connect to Azure SQL Data warehouse using PDO - php

I am using Laravel 5 and want to connect to a Azure Data warehouse using the implemented PDO database connection Laravel provides. I am using the following connection settings.
DB_CONNECTION=sqlsrv
DB_HOST=tcp:srv.url.com,1433
DB_DATABASE=db-name
DB_USERNAME=user
DB_PASSWORD=pass
When I load the page I get a "could not find driver" error.
How is this possible? The drivers are build into Laravel rigth?
Thanks in advance!

You need to install the PDO driver for sqlsrv manually, configure in PHP PDO_SQLSRV extension enabled by adding appropriate DLL file like php_pdo_sqlsrv_53_nts.dll, and which is only compatible with PHP running on Windows. You can refer to http://php.net/manual/en/ref.pdo-sqlsrv.php for more info.
To connect to SQL server in PHP in Unix, you can use ODBC extension and Microsoft's SQL Server ODBC Driver for Linux.

Related

PHP Laravel PDO MSSQL Data Source Name Not Found on Mac OS

I'am currently trying to connect on MSSQL server using the sqlsrv driver of the laravel 8 and its default connection is using PDO MSSQL, I already manage to connect using sqlsrv only and the driver is already loaded in the php info but the PDO MSSQL still encounter the following error in the laravel 8 framework.
I already install the odbc using this instructions
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos
Below is the odbcinst.ini and for my odbc.ini it is empty
Fixed by editing the odbc.ini in both user and system settings the path are below:
System = /Library/ODBC/odbc.ini
User = ~/Library/ODBC/odbc.ini
Then the Laravel PDO Driver read the Data source,

PDO_DBLIB Vs. PDO_SQLSRV

What is the best PDO driver to connect SQL server from php. So far I have found found two extension:
sybase DBLIB
Microsoft official driver for SQL server as specified here here. It works in php7. It works on linux. I have installed. It is working
I installed DBLIB at first place. But DBLIB is showing following error very randomly:
SQLSTATE[01002] Adaptive Server connection failed (severity 9)
It is not for config. Reason if I reload the page that error goes off and everything starts perfectly. It happens very randomly and rarely.
Using Microsoft official driver will help me in this case? Can you please suggest me what shall I do? Which will be better driver to connect sql server and also solves that randomly occurring problem?
DBLIB is becoming obsolete. We need to use PDO_SQLSRV in all place

Connect Silex to MSSQL Server

Does anyone know how to connect a Silex based Web Application to a MSSQL DB?
I tried the https://packagist.org/packages/localgod/pdo-service-provider
but don't know which driver I have to use.
You shouldn't over think it, at the end you're just using PDO so check the PDO's manual and use the SQLSRVR driver.
NOTE: I've never used PDO in Ms SQL, but once installed the driver it should be straight forward to use, from the comments on the SQLSRV:
As of 12/12/2014, Microsoft has officially released Version 3.1.
Support for 5.5 has 4 drivers php_pdo_sqlsrv_55_nts.dll
php_pdo_sqlsrv_55_ts.dll php_sqlsrv_55_nts.dll php_sqlsrv_55_ts.dll
Note: Version 3.1 now supports PHP 5.5 and requires Microsoft ODBC
Driver 11 (or higher)
You can downlod the new driver from
http://www.microsoft.com/en-us/download/details.aspx?id=20098
So, once enabled you can just use the sqlsrv and this should work (or you can skip this provider and use raw PDO: $c = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");)
Edited to give Linux/Unix instructions:
If you are running your PHP code from linux, you just need to use de default ODBC driver (from the docs: The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and ยป Microsoft's SQL Server ODBC Driver for Linux.)
Also take a look at this answer.

Connecting to MS SQL Server in PHP

I'm running a WAMP stack and and trying to connect to an SQL Server instance with PHP's PDO.
I've downloaded the PHP drivers for MS SQL from here and added **php_pdo_sqlsrv_54_ts.dll** into PHP's extension folder.
Then added "php_pdo_sqlsrv_54_ts.dll" to the list of extensions in php.ini.
I know I'm using the correct driver because I'm using PHP version 5.4.3 and **phpinfo()** reports that it's thread-safe.
However, after restarting Apache **phpinfo()** (and **PDO::getAvailableDrivers()**) both report that only the mysql, odbc and sqlite PDO drivers are loaded.
This means that when I attempt to connect to my SQL Server instance I get the error:
could not find driver
Can anyone advise on how to get this working?
Sounds like the SQL Native Client is missing.
System Requirements
Microsoft SQL Server 2012 Native Client available in the SQL Server 2012 Feature Pack.

Connecting to Teradata via PHP

We need to access a Teradata database via php application We don't have odbc (unixodbc etc) on the server.
How might one go about connecting to a teradata database quickly.
Keep in mind - this app needs to be as portable as possible.
Teradata provides an ODBC driver. Once installed, it can be accessed via the unixODBC driver manager, assuming your php was built with "--with-unixODBC=shared,/usr".
PHP can then connect to a Teradata database with odbc_connect($dsn, $user, $passwd);
The Teradata ODBC driver installation includes a sample odbc.ini file, which you can cp to .odbc.ini in your home directory, then modify to contain the DSN for your Teradata database.
Set the environment variable ODBCINI to the location of your odbc.ini file to use (/home/johndoe/.odbc.ini is common).
Be warned: the Teradata ODBC driver provides a rich set of DML statements, but very few are exposed through the unixODBC driver manager. The collection of PHP's odbc_xxxx() functions is a crippled subset of what the Teradata ODBC driver offers.
This method would help you if u are ok with the memory implications and this would help you if you have teradata command line utility BTEQ installed on your machine.
But better method would be by ODBC as it gives you the flexibility. In the above method of command line execution of SQL scripts by system() function, you can use an easier language like R for parsing the output resultset.
I think you may also do it by jdbc connection. You can also download any of these odbc/jdbc drivers from this link.
You may be out of luck.
PDO doesn't have a native driver
ADODb doesn't have a native driver
judging from what I find from a cursory web search, I'd say it is not possible to connect from PHP to a Teradata database without ODBC.

Categories