Jump to content


Photo

Unique Identifiers & Select Queries to MSSQL in PHP


  • Please log in to reply
No replies to this topic

#1 intergroove

intergroove
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 October 2006 - 08:22 PM

Help.

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...





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users