Should I use PHP's SQLSRV Functions? - php

I am starting a new project in PHP that need to access MS Sql Server.
I know that PHP's manual lacks of warns about old or even deprecated set of functions.
MySQL extension do not refer to MySQLi extension at any point.
SQLite extension do not refer to SQLite3 extension at any point.
So my question is: Am I OK using PHP's SQLSRV Functions? or they are not the state of the art? I did choose them because aparently they have MS support.
Please notice that I am not asking for a recomendation, just if what I choose is OK

As I understand it the SQLSRV functions aren't actually PHP's per se since they are part of a package maintained by Microsoft outside the main PHP project. They are however one of the two best bets for working with MS SQL Server (PDO_SQLSRV being the other) since they are currently maintained.
They are both currently Windows only.

Related

Is mysqli extension ubiquitous since PHP 5.3?

We have developed a web-application that runs on various server environments (> PHP 5.3), which currently uses the "deprecated" mysql extension to connect to mysql. Since PHP 7 however, it seems mysql is not installed by default, only the newer mysqli extension.
So we would like to convert our scripts to use mysqli, but we are concerned if the mysqli extension is not installed on "older" servers. So the question basically goes: Is mysqli generally ubiquitous since PHP version 5.3? Does anyone know from what version of PHP mysqli comes installed as default?
If some of our users are on hosts without mysqli, we would need to create a wrapper script, that detects if mysqli is available, and fall back to mysql if not.
Anyone with knowledge care to shine some light on this? Thanks
MySQLi was added with PHP 5.0
You can check if mysqli is installed by doing this:
if ( function_exists('mysqli_connect') )
// mysqli is installed

Will mysql extension remain or will it be replaced by mysqli?

I have a old php script (very long,over a year worth of coding) running on a old pc on the lan with a old xxamp setup. The php script is so old that it contains the <?php formatting! This PC will now be replaced but the php script still needs to work. I will switch pc, update xampp to the latest version and migrate everything. I am aware that I'll have to update the old php coding but I am wondering if the whole mysql part MUST be ported to mysqli or if mysql will still exist for the next lets say 10 years. I couldnt find any information on the web.
Thanks
As stated in the comments and on the mysql_connect() page on php.net.
This extension is deprecated as of PHP 5.5.0, and will be removed in
the future. Instead, the MySQLi or PDO_MySQL extension should be used.
It's deprecated and will be removed from php in the future. There is no set date, but I can guarantee you that the use of this should stop as soon as possible. Save yourself some heartache and get cracking into PDO or MySQLi. It'll do your script the world of good!
Mysql is already deprecated. You can either use mysqli or PDO in order to handle PHP with MySql.
I'm already using PHP 5.6 on a local server, and had to rewrite parts of the class I use to connect to the DB: on 5.6, mysql extension has already been removed.
I suggest you to use PDO instead of mysqli (it's a bit more powerful, but of course, it's a personal opinion).

Sqlserv extension on mac

My company uses the sqlserv extension to connect to a MSSQL database. This extension was chosen over the mssql extension because it is actively being maintained by Microsoft and the mssql driver is no longer maintained at all. My colleague has always worked in a windows enviroment so he could just download the proper DLL file and voila, sqlserv is available. Since i am running on Mac OSX 10.8.1 i don't share this luxery.
So basically the question is: does anyone know of a sqlserv php extension in the form of a .so file?
You cannot run the SQLSRV extension on anything other than Windows as stated here:
http://php.net/manual/en/sqlsrv.installation.php
However, even if you could, I would strongly urge you to stay away from the SQLSRV extension as it is extremely buggy and underdeveloped. You would be much better off using PDO!
I spent days trying to work out which extension to use, and after much research and questions on stackoverflow, it was clear that PDO was the only realistic solution for connecting to an MSSQL database. Not to mention the additional functionality that you have!
Try and execute stored procedures, return multiple recordsets along with output parameters using the SQLSERV extension!! Just one of the many features that can be done in a few lines with PDO but cannot be done with SQLSERV.
Furthermore, PDO is faster!

mssql_connect no longer working as of PHP 5.3

I just received an email from our host and they've upgraded our PHP to 5.3, unfortunately though, all the scripts have now broken. I traced it down to the function mssql_connect failing. Support told me this has now been deprecated under 5.3 - how can this be true?
How can you connect to a mssql database under PHP 5.3 now??
http://www.php.net/manual/en/intro.mssql.php
"This extension is not available anymore on Windows with PHP 5.3 or later."
Maybe you should look into converting your app to use PDO:
http://www.php.net/manual/en/ref.pdo-sqlsrv.php
If you see such a warning, the first place to visit is the PHP documentation.
From http://php.net/manual/en/intro.mssql.php:
Introduction
These functions allow you to access MS SQL Server database.
This extension is not available anymore on Windows with PHP 5.3 or
later.
SQLSRV, an alternative driver for MS SQL is available from Microsoft:
ยป http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.

Trouble using MsSQL with PHP

I am debating between using MsSQL and SQLSrv to connect to SQL Server.
Our platform is running IIS7 on Windows and using PHP. We tried using the MsSQL extension to work but had problems so we decided to use SQLSrv instead since it was easier to get working.
Using MsSQL would be the preferred option because it fits the workflow better and the function names are similar to the ones used in SQL. Is it worth the effort to use MsSQL with PHP in light of the problems we are facing or should we use SQLSrv with the downsides mentioned.
Also, on the MSDN Docs for SQLSrv it mentions that the documentation is for preview and might change. Does that mean the functions could end up changing?
As far as the notice on the documentation all it means is they may change the wording of the document later in its release, I can't promise that the functions will stay the same however nothing on that page leads me to believe otherwise. Here is a Microsoft Wiki article on Accessing SQL Server Databases from PHP is says that the process outlined on that page is compatible with SQL Server 2005, SQL Server 2008, and SQL Server 2008 R2 so the software should not change since it needs to maintain compatibility with older versions of SQL Server.
You may also want to reference that wiki article, it contains step by step setup procedures for MsSQL and SQLSrv which may work for you and fix the issue you have.

Categories