php-sqlsrv/test/functional/pdo_sqlsrv/pdo_errorMode.phpt

41 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-05-03 18:53:22 +02:00
--TEST--
Test different error modes. The queries will try to do a select on a table that does not exist on database.
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
2017-05-03 18:53:22 +02:00
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");
2017-05-03 18:53:22 +02:00
function testException()
{
2017-05-03 22:09:02 +02:00
$db = connect();
$sql = "SELECT * FROM temp_table";
try {
2017-05-03 18:53:22 +02:00
$q = $db->query($sql);
} catch (Exception $e) {
2017-05-03 18:53:22 +02:00
echo 'Caught exception: ', $e->getMessage();
}
}
function testWarning()
{
2017-10-11 00:56:41 +02:00
$db = connect("", array(), PDO::ERRMODE_WARNING);
2017-05-03 22:09:02 +02:00
$sql = "SELECT * FROM temp_table";
2017-05-03 18:53:22 +02:00
$q = $db->query($sql);
}
function testSilent()
{
2017-10-11 00:56:41 +02:00
$db = connect("", array(), PDO::ERRMODE_SILENT);
2017-05-03 22:09:02 +02:00
$sql = "SELECT * FROM temp_table";
2017-05-03 18:53:22 +02:00
$q = $db->query($sql);
}
testException();
testWarning();
testSilent();
?>
--EXPECTREGEX--
Caught exception: SQLSTATE\[42S02\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Invalid object name 'temp_table'\.
Warning: PDO::query\(\): SQLSTATE\[42S02\]: Base table or view not found: 208 \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Invalid object name 'temp_table'\. in .*pdo_errorMode\.php on line [0-9]+