-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added error handling for emulate prepare with output parameter
- Loading branch information
1 parent
2aec3b4
commit 6d7cddf
Showing
4 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
test/pdo_sqlsrv/pdoStatement_bindParam_inout_emulate_prepare.phpt
This file contains 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
52 changes: 52 additions & 0 deletions
52
test/pdo_sqlsrv/pdoStatement_bindParam_output_emulate_prepare.phpt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--TEST-- | ||
Tests error returned when binding output parameter with emulate prepare | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
require_once("autonomous_setup.php"); | ||
|
||
$database = "tempdb"; | ||
$dsn = "sqlsrv:Server=$serverName ; Database = $database"; | ||
try { | ||
$conn = new PDO($dsn, $username, $password); | ||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
|
||
$count = 0; | ||
|
||
$query = "select ? = count(* ) from cd_info"; | ||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true)); | ||
$stmt->bindParam( 1, $count, PDO::PARAM_STR, 10 ); | ||
$stmt->execute(); | ||
echo "Result: ".$count."\n"; | ||
|
||
$query = "select bigint_type, int_type, money_type from [test_types] where int_type < 0"; | ||
$stmt1 = $conn->prepare($query); | ||
$stmt1->execute(); | ||
$row = $stmt1->fetch( PDO::FETCH_ASSOC ); | ||
print_r($row); | ||
|
||
$int = 0; | ||
$bigint = 100; | ||
$query = "select ? = bigint_type, ? = int_type, ? = money_type from [test_types] where int_type < 0"; | ||
$stmt2 = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true)); | ||
$stmt2->bindparam( 1, $bigint, PDO::PARAM_STR, 256 ); | ||
$stmt2->bindParam( 2, $int, PDO::PARAM_INT, 4 ); | ||
$stmt2->bindParam( 3, $money, PDO::PARAM_STR, 1024 ); | ||
$stmt2->execute(); | ||
echo "Big integer: ".$bigint."\n"; | ||
echo "Integer: ".$int."\n"; | ||
echo "Money: ".$money."\n"; | ||
|
||
//free the statement and connection | ||
$stmt = null; | ||
$stmt1 = null; | ||
$stmt2 = null; | ||
$conn = null; | ||
|
||
} | ||
catch(PDOException $e) { | ||
print("Error: " . $e->getMessage() . "\n"); | ||
} | ||
?> | ||
--EXPECT-- | ||
Error: SQLSTATE[IMSSP]: Statement with emulate prepare on does not support output or input_output parameters. |