Unique Identifiers & Select Queries to MSSQL in PHP
Posted: Wed Oct 11, 2006 4:55 pm
This has been bugging me for a couple of days now:
I am writing a script to regularly transfer data from a MYSQL db to a MSSQL.
Being new to MSSQL I'm a bit freaked out about the UNIQUEIDENTIFER (UI) system.
I have to INSERT data to a table where I need the UI for items from 2 other tables. This negates my ability to use a JOIN. So I need to grab the UI from within PHP and the reference the variable in the query.
To test this I am using a simple SELECT:
First I need to get the UI:
SELECT CAST(CATALOGGUID as VARCHAR(36)) as CGUID FROM CATALOG WHERE CATALOGNAME='TESTCATALOG'
I then assign CGUID to $CGUID
The problem query is now:
SELECT * FROM CATALOG WHERE CATALOGGUID = '".$CGUID."';
I have tried wrapping the string with curly brackets { & }. But it won't work.
I copy the query and put it into SQL QUERY ANALYZER then it works perfectly. The problem is just from inside PHP.
Has anybody else had this problem? or knows of a solution?
The server OS is Windows 2003 Server. PHP is 5+.
Thanx in advance...
I am writing a script to regularly transfer data from a MYSQL db to a MSSQL.
Being new to MSSQL I'm a bit freaked out about the UNIQUEIDENTIFER (UI) system.
I have to INSERT data to a table where I need the UI for items from 2 other tables. This negates my ability to use a JOIN. So I need to grab the UI from within PHP and the reference the variable in the query.
To test this I am using a simple SELECT:
First I need to get the UI:
SELECT CAST(CATALOGGUID as VARCHAR(36)) as CGUID FROM CATALOG WHERE CATALOGNAME='TESTCATALOG'
I then assign CGUID to $CGUID
The problem query is now:
SELECT * FROM CATALOG WHERE CATALOGGUID = '".$CGUID."';
I have tried wrapping the string with curly brackets { & }. But it won't work.
I copy the query and put it into SQL QUERY ANALYZER then it works perfectly. The problem is just from inside PHP.
Has anybody else had this problem? or knows of a solution?
The server OS is Windows 2003 Server. PHP is 5+.
Thanx in advance...