Skip to content

Instantly share code, notes, and snippets.

@bennettblack
Last active July 12, 2022 21:47
Show Gist options
  • Save bennettblack/765b840bd3b910178f0aa6b04085a447 to your computer and use it in GitHub Desktop.
Save bennettblack/765b840bd3b910178f0aa6b04085a447 to your computer and use it in GitHub Desktop.
DB2 for IBM i Series stored procedure call (Laravel)
<?php
use Illuminate\Support\Facades\DB;
use PDO;
class ClassName {
public static function methodName(String $customer, String $item_number){
$input_param = 'blah';
$input_param_2 = 'blah';
$output_param = ''; // or zero if expecting number
$output_param_2 = ''; // or zero if expecting number
$sql = "CALL SCHEMA.PROCEDURE_NAME(:input_param, :input_param_2, :output_param, :output_param_2)";
$stmt = DB::getPdo()->prepare($sql);
$stmt->bindParam(':input_param', $input_param, PDO::PARAM_STR);
$stmt->bindParam(':input_param_2', $input_param_2, PDO::PARAM_STR);
$stmt->bindParam(':output_param', $output_param, PDO::PARAM_STR, 9); // Must define length on output param
$stmt->bindParam(':output_param_2', $output_param_2, PDO::PARAM_STR, 10); // Must define length on output param
$stmt->execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment