added catch block in pdo_warnings.phpt
This commit is contained in:
parent
6fb68c9b61
commit
caec680535
|
@ -1,5 +1,5 @@
|
|||
--TEST--
|
||||
Test setting invalid value or key i connection attributes
|
||||
Test setting invalid value or key in connection attributes
|
||||
--SKIPIF--
|
||||
|
||||
--FILE--
|
||||
|
@ -8,19 +8,19 @@ Test setting invalid value or key i connection attributes
|
|||
require_once("autonomous_setup.php");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
// Negative value for query timeout: should raise error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_QUERY_TIMEOUT, -1 );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
// Negative value for query timeout: should raise error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_QUERY_TIMEOUT, -1 );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
|
||||
// PDO::ATTR_CURSOR is a Statement Level Attribute only
|
||||
@$conn->setAttribute( PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
// PDO::ATTR_CURSOR is a Statement Level Attribute only
|
||||
@$conn->setAttribute( PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
|
|
|
@ -8,25 +8,25 @@ Test setting invalid encoding attributes
|
|||
require_once("autonomous_setup.php");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
// valid option: should have no error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
// valid option: should have no error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
|
||||
// PDO::SQLSRV_ENCODING_UTF8 should not be quoted
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, "PDO::SQLSRV_ENCODING_UTF8" );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
// PDO::SQLSRV_ENCODING_UTF8 should not be quoted
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, "PDO::SQLSRV_ENCODING_UTF8" );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
|
||||
// PDO::SQLSRV_ENCODING_BINARY is not supported
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_BINARY );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
// PDO::SQLSRV_ENCODING_BINARY is not supported
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_BINARY );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
|
|
|
@ -4,6 +4,7 @@ Test warnings on connection and statement levels
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
try{
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
|
||||
|
@ -20,6 +21,11 @@ Test warnings on connection and statement levels
|
|||
|
||||
$statement = NULL;
|
||||
$conn = NULL;
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
var_dump( $e->errorInfo );
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
Warning: SQLSTATE: IMSSP
|
||||
|
|
Loading…
Reference in a new issue