Jump to content

SQLSRV_ conversion


Paladindc

Recommended Posts

Hi all,

 

Hopefully this will be a simple one for all you geniuses...Geniea... clever people out there.  :?

 

I'm trying to convert the following code from a mysql_ to sqlsrv_ statement. I have to admit i am a bit of a noob, but am learning fast! The code was originally developed by dreamweaver with some webassist extensions.

 

  $conn4 = sqlsrv_connect($hostname, $connectionInfo);

  if (!session_id()) session_start();

  $insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);

  $WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";

  $MM_editCmd = sqlsrv_query($conn4, $WA_Sql) or die(print_r( sqlsrv_errors(), true));

  $_SESSION[$WA_sessionName] = sqlsrv_insert_id();

  if ($WA_redirectURL != "")  {

    if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {

      $WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];

    }

 

I appear to have had some luck with other parts of the code renaming mysql_ statements with the appropriate sqlsrv variations and some (slight) code re-hashing, but the above has given me a bit of a headache  :banghead: . I assume that I need to break the  "$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";" into two parts to give the sqlsrv_query it's `resource`, `array`, `parameter` format (I think that's right!), but i might be wrong.

 

If it's all completely wrong, I apologise!

 

Unfortunately due to the nature of the project Microsoft SQL is a necessary evil, and PDO has been considered but my brain is exploding with a (near straight) conversion as is... Unless anyone knows of a mysql to PDO conversion utility....or really easy method???

 

Would anyone be kind enough to help me with this?

 

Regards

 

Paladindc

 

"In an ideal world, there would be no ideals, therefore would it indeed be ideal?" - Me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.