Created
February 25, 2017 15:31
-
-
Save REPTILEHAUS/649b5580ea262c52e6c558aa20e9652d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Change to your hosts IP, username, password and database name | |
| define('HOST','localhost'); | |
| define('USER','root'); | |
| define('PASS',''); | |
| define('DB','storedprocedures'); | |
| $dbh = @new mysqli(HOST, USER, PASS, DB); | |
| if( mysqli_connect_errno() ) { | |
| print('could not connect: %s\n').mysqli_connect_errno(); | |
| exit(); | |
| } | |
| // This is ID we feed to the stored procedures INPUT ':usersession'. The OUTPUT | |
| // variable that related to this ID is stored in the MySQL user variable | |
| // '@output_name'. $id = 4; | |
| // Call our stored procedure by feeding in an id and getting out a user variable | |
| // of the name relative to the id in our table | |
| $stmt = $dbh->query("CALL getMemeber_sproc('$id', @output_name)"); | |
| // SELECT the user variable for use in our script | |
| $outputArray = $dbh->query("SELECT @output_name")->fetch_assoc(); | |
| print "procedure returned " . $outputArray['@output_name'] . "\n"; | |
| mysqli_close($dbh); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment