Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlsrv_query with $params containing a NULL redefines NULL in php #2

Closed
v-mabarw opened this issue Jul 29, 2014 · 1 comment
Closed

Comments

@v-mabarw
Copy link
Contributor

When a NULL value exists in the parameters when calling sqlsrv_query, it
replaces the PHP NULL value with a reference. All variables end up containing
the same value.

E.g.
$params = array('abd' 'def', NULL);
sqlsrv_query($conn, $tsql, $params);

NULL is now a reference, so:
$newVar = '123'; // ALL null values now become '123'
$otherVar = '456' // $newVar, $otherVar and $params[2] are all '456', along
with any other variables that happen to be NULL.

I posted this in the MSDN forum: [ http://social.msdn.microsoft.com/Forums/en-
US/sqldriverforphp/thread/b4f0fdc1-62ce-4449-95f1-a9536311223a
](http://social.msdn.microsoft.com/Forums/en-
US/sqldriverforphp/thread/b4f0fdc1-62ce-4449-95f1-a9536311223a)

Sorry, I'm not great at describing things.

Work Item Details

Original CodePlex Issue: Issue 12205
Status: Closed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Dec 24, 2008 at 9:28 AM
Reported by: robertjohnson
Updated on: May 29, 2009 at 8:45 PM
Updated by: icosahedron
Closed on: May 29, 2009 at 8:45 PM

@v-mabarw
Copy link
Contributor Author

On 2009-05-30 03:44:49 UTC, icosahedron commented:

The workaround is to add a & to each parameter. This is now documented in CU2. When a variable without an & is passed as a parameter, a warning is issued as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant