#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    6
    Rep Power
    0

    Exclamation PHP MSSQL Syntax for stored proceedures




    I need to know how to call a stored proceedure in MS SQL using PHP on a Windows NT server.

    I searched the net to find all references to calling one on a Linux server using the PHP functions 'mssql_'.

    Here is how i do it now:

    PHP Code:
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 
    $conn->Open("PROVIDER=SQLOLEDB;DRIVER={SQL SERVER};Server=MY_SERVER;Database=MY_DATABASE;UID=MY_USERNAME;PWD=MY_PASS;"); 

    // HERE IS WHAT THE STORED PROCEEDURE SAYS IN SQL SERVER
    //
    // Select * from tbl_countries
    //

    $sql "procTestCall";

    $rs $conn->Execute($sql);

    while (!
    $rs->EOF) {
        
        
    $fv $rs->Fields("COUNTRY");
        
    $display $fv->value;

        
    $rs->MoveNext();
    }
    $rs->Close(); 
    I need to know how to send a parameter/ variable to the stored proceedure & how to retrieve them back using this method.

    Any help is appreciated.

    Cheers.
  2. #2
  3. #3
  4. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    95
    Rep Power
    11
    sorry to bump this old thread, but this is exactly what I need to do and the link given is broken.
  5. #4
  6. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    95
    Rep Power
    11
    http://www.devarticles.com/c/a/PHP/E...-PHP-on-Linux/

    sorry, link wasn't broken, just didn't point to the exact article
  7. #5
  8. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    538
    Yeah, they seem to have reorganized their site.
    Note that this is not the only way of connecting to a remote MSSQL server from Linux.
    Check http://sourceforge.net/projects/odbtp/ to see an example (which works with Access also).
  9. #6
  10. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    95
    Rep Power
    11
    Okay.. I still need help in getting results from the MSSQL's stored procedures.

    I followed the directions in the article and edited and recomplied my PHP source... but I have a question on how to bind variables to my procedure call... they only give one example and I think I need more.

    I have a stored procedure that returns several rows... how would I bind a result? In the example they just show the binding of a result if just expecting a single integer value.



    Also, I tried doing the simple thing such as:

    $dbquery="EXECUTE storedProcedure 'parameter'";
    $result = mssql_query($dbquery);

    But I get timeouts....

IMN logo majestic logo threadwatch logo seochat tools logo