Skip to content

Instantly share code, notes, and snippets.

@phpdave
Created September 22, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpdave/99f2d573cc4523c2641f3be678f280c9 to your computer and use it in GitHub Desktop.
Save phpdave/99f2d573cc4523c2641f3be678f280c9 to your computer and use it in GitHub Desktop.
<?
//Create db connection
$hostname = "MYIBMI";
$user = "MYPROFILE";
$password = "";
$dbconn = new PDO("odbc:" . $hostname, $user, $password);
//SQL to run stored proc
$sql = "call #LALLAN.getCusInfo(?, ?, ?, ?)";
//Prepare SQL for execution
$stmt = $dbconn->prepare($sql);
//Create a test object for demo purposes
$Customer = new stdClass();
$Customer->ID = 1;
$Customer->Data1 = "";
$Customer->Data2 = "";
$Customer->Data3 = 1;
//Bind object properties to our object
$stmt->bindParam(1, $Customer->ID, PDO::PARAM_INT);
$stmt->bindParam(2, $Customer->Data1, PDO::PARAM_INPUT_OUTPUT);
$stmt->bindParam(3, $Customer->Data2, PDO::PARAM_INPUT_OUTPUT);
$stmt->bindParam(4, $Customer->Data3, PDO::PARAM_INPUT_OUTPUT);
//Run it
$stmt->execute();
//Dump our object to the screen to see what everything got set to. Or alternatively run xdebug or another debugger to view the $Customer object after execution
var_dump($Customer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment