Connect Silex to MSSQL Server - php

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.

Related

running a codeigniter application on localhost/xampp

What versions of PHP and MYSQL should I use, if I want to run a codeigniter application of version 2.2.0 on my XAMPP local host?
Thanks in advance.
Codeigniter 2.2.0 needs below Server Requirements
PHP version 5.1.6 or newer.
A Database is required for most web application programming. Current supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC.
PHP version 5.6 or newer is recommended.
It should work on 5.3.7 as well, but we strongly advise you NOT to run such old versions of PHP, because of potential security and performance issues, as well as missing features.
A database is required for most web application programming. Currently supported databases are:
MySQL (5.1+) via the mysql (deprecated), mysqli and pdo drivers
Oracle via the oci8 and pdo drivers
PostgreSQL via the postgre and pdo drivers
MS SQL via the mssql, sqlsrv (version 2005 and above only) and pdo drivers
SQLite via the sqlite (version 2), sqlite3 (version 3) and pdo drivers
CUBRID via the cubrid and pdo drivers
Interbase/Firebird via the ibase and pdo drivers
ODBC via the odbc and pdo drivers (you should know that ODBC is actually an abstraction layer)
Link Server Requirements
Upgrading to Code Igniter 2.2.0
Code Igniter 2.2.0 can be upgraded to (or installed) using any of Installatron's products. Use Installatron's optional Automatic Update feature to automatically apply Code Igniter updates as new versions are released, or use Installatron's Clone feature to duplicate an existing Code Igniter install to test the 2.2.0 upgrade prior to applying it live. Get started managing your Code Igniter installations with Installatron
What's New in Code Igniter 2.2.0
This is a security release for the 2.x branch. The Encryption Class now requires the Mcrypt extension, so please ensure your environment is ready for the update.
General Changes
Security: The xor_encode() method in the Encrypt Class has been removed. The Encrypt Class now requires the Mcrypt extension to be installed.
Security: The Session Library now uses HMAC authentication instead of a simple MD5 checksum.
Bug Fixes
Fixed an edge case (#2583) in the Email Library where Suhosin blocked messages sent via mail() due to trailing newspaces in headers.
Fixed a bug (#696) - make oci_execute() calls inside num_rows() non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed.
Fixed a bug (#2689) - Database Forge Class methods create_table(), drop_table() and rename_table() produced broken SQL for tge 'sqlsrv' driver.
Fixed a bug (#2427) - PDO Database driver didn't properly check for query failures.
Fixed a bug in the Session Library where authentication was not performed for encrypted cookies.

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.

Laravel mssql driver support

I have been searching mssql driver for Laravel framework, but had no luck so far. I know Laravel has sqlsrv support for sql servers, but what I need is mssql connector (ones that have functions starting with 'mssql_').
We cannot use sqlsrv because most of our servers are MSSQL 2000, and sqlsrv doesn't provide support for these servers as far as I know. Also, MS does not provide sqlsrv driver for linux. (We are using freetds driver with manually compiled php 5.4.8 on Fedora 17 64-bit).
My question is
Is there any patch for mssql support in Laravel?
If not, which files should I create/modify to have mssql supported if it is ever possible?
I could use different framework that supports mssql as well, but I really like how Laravel handles everything. I didn't want to give up on Laravel just because it doesn't support mssql.
It seems it does not include that driver... I believe you can setup it at laravel/database/connectors

What is diffrence between odbc_connect() and mssql_connect()

In php, to connect to MSSQL server , what is diffrence between odb_connect() and mssql_connect()???
odbc_connect is a generic database connection (you can specify the driver), while mssql_connect is MSSQL specific
Also the manual says that complex queries may fail with odbc drivers.
odbc_connect() requires you have the PHP ODBC extension loaded and UNIXodbc installed and configured on the web server, whereas mssql_connect() only requires that you have the MSSQL extension.
If your looking to connect to a SQL Server via PHP, might I recommend that you use Microsoft's SQLSRV PHP driver. It's much better than the native php_mssql extension and gives you a lot more functionality. Make sure you also install SQL Server native client, or it won't work.

PHP ORM with support for SQL Server 2005

I have been looking around the current options (and related SO questions) regarding PHP ORM solutions, however I have a couple of unique requirements:
I am running PHP on Windows Server 2003
I need to interface with SQL Server 2005
I can't seem to find a simple answer from the PHP ORM solutions out there as to which (if any) support MSSQL as an adaptor option. Outlet seems to support this, for instance, but is only mentioned in passing on the documentation page, while other references say that the current version (1.0) has only been tested with MySQL.
At the moment, I am using the Microsoft PHP SQL Server driver, which as I understand it, can't be used with current ORM solutions until the driver itself supports PDO (which the team are looking into, but with no timeframe).
So what can I use today as an ORM solution on PHP for Windows that interfaces with SQL Server. Anything out there at all?
From Doctrine manual:
The currently supported PDO database drivers are:
fbsql FrontBase
ibase InterBase / Firebird (requires PHP 5)
mssql Microsoft SQL Server (NOT for Sybase. Compile PHP --with-mssql)
mysql MySQL
mysqli MySQL (supports new authentication protocol) (requires PHP 5)
oci Oracle 7/8/9/10
pgsql PostgreSQL
querysim QuerySim
sqlite SQLite 2
And PHP on Windows should ship with an appropriate extension for MSSQL for PDO. Just enable
extension=php_pdo.dll
extension=php_pdo_mssql.dll
Propel should also support MSSQL, as it is written on top of PDO. And while not a full fledged ORM as such, Zend_Db has an adapter for MSSQL as well. The latter uses pdo-dblib though.

Categories