PHP‎ > ‎

Execute a stored procedure with parameters using PDO

THIS CODE WORKS WITH A SQL SERVER DATABASE:


$connGP = new PDO( "sqlsrv:Server=10.10.10.5;Database=TEST", "userid", "password");


$sql = "exec spICB_CustomerIntegration ?,?,?,?,?,?,?,?,?,?,?,?,?";
$stmt = $connGP->prepare($sql);

$customernumber="JODEV123";
$class="RETAIL";
$name="DEVIN TEST";
$address1="10333 W. 62nd ave.";
$address2="";
$city="Arvada";
$state="CO";
$zip="80004";
$country="United States";
$shopifyid="1111";
$contact="Devin Johnson";
$taxschedule="EXEMPT";
$errorstring="";


$stmt->bindParam(1, $customernumber, PDO::PARAM_STR);
$stmt->bindParam(2, $class, PDO::PARAM_STR);
$stmt->bindParam(3, $name, PDO::PARAM_STR);
$stmt->bindParam(4, $address1, PDO::PARAM_STR);
$stmt->bindParam(5, $address2, PDO::PARAM_STR);
$stmt->bindParam(6, $city, PDO::PARAM_STR);
$stmt->bindParam(7, $state, PDO::PARAM_STR);
$stmt->bindParam(8, $zip, PDO::PARAM_STR);
$stmt->bindParam(9, $country, PDO::PARAM_STR);
$stmt->bindParam(10, $shopifyid, PDO::PARAM_STR);
$stmt->bindParam(11, $contact, PDO::PARAM_STR);
$stmt->bindParam(12, $taxschedule, PDO::PARAM_STR);
$stmt->bindParam(13, $errorstring, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,500);

$stmt->execute();


Comments