Can any one give The Example php code for connecting and getting a sql stored proceedure
            Asked
            
        
        
            Active
            
        
            Viewed 494 times
        
    2 Answers
1
            
            
        what do you prefer to use? Here is an example taken from php.net:
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$query  = "CALL get_items(1, @param1, @param2); "; 
/* execute multi query */
if ($mysqli->multi_query($query)) {
    do {
        /* store first result set */
        if ($result = $mysqli->store_result()) {
            while ($row = $result->fetch_row()) {
                printf("%s\n", $row[0]);
            }
            $result->free();
        }
        /* print divider */
        if ($mysqli->more_results()) {
            printf("-----------------\n");
        }
    } while ($mysqli->next_result());
}
/* close connection */
$mysqli->close();
remember, that you have to free the resultset, if you do not, you will get an error while executing a next query.
Before I know something about mysqli, I apply mysqli to handle sp's. Just take a look at the follwing example:
$rs = mysql_query("CALL get_items(1, @param1, @param2); ");
$rs = mysql_query("SELECT @param1, @param2" );
while($row = mysql_fetch_assoc($rs))
{
    print_r($row); 
}
 
    
    
        Tobias Bambullis
        
- 736
- 5
- 17
- 45
0
            
            
         
    
    
        Phill Pafford
        
- 83,471
- 91
- 263
- 383
- 
                    1The link above has a ton of example code, Did you visit the link? – Phill Pafford Oct 14 '10 at 20:49
 
    