Skip to content
Advertisement

mssql_bind empty string converting to NULL

I am currently using SQL Server 2000 Stored Procedures with PHP. Following the PHP doc, I use mssql_bind to assign value of parameters and then execute the Stored Procedure.

The problem is that I got this bug which prevents me to bind empty strings to parameters (they are converted to NULL when the Stored Proc gets called)

I dont’t want to have to convert every parameter inside the Stored Procedures to check if its NULL then convert back to an empty string. I want to be able to use empty strings as well as NULL which both have their own meaning.

Does anyone know a workaround for this in PHP ? PHP bugs website isn’t very clear if that bug is fixed or when it will be fixed, I use PHP 5.2.11 (the lastest version from the 5.2 branch)

Advertisement

Answer

Assuming you do not want to do what you suggested, options left to you are

  1. Download a cvs snapshot of php and install it if viable, see if it is fixed. If not viable or fixed via cvs then…
  2. Use system() or exec() calls to use the stored procedures. If too much a hassle then…
  3. Don’t use stored procedures, do your functionality in php or other scripting code.
  4. Alter the stored procedure to accept another value for ” strings and convert THAT to a ” string.
  5. Do what you didn’t want to do. Harsh 😛 But I do not see another way.
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement