php-sqlsrv/test/functional/sqlsrv/TC31_SimpleQuery.phpt

58 lines
1.2 KiB
Plaintext
Raw Normal View History

2017-05-04 01:00:31 +02:00
--TEST--
Simple Query Test
--DESCRIPTION--
Basic verification of query statements (via "sqlsrv_query"):
2017-05-04 01:00:31 +02:00
- Establish a connection
- Creates a table (including all 28 SQL types currently supported)
- Executes a SELECT query (on the empty table)
- Verifies the outcome
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
2017-05-04 01:00:31 +02:00
--FILE--
<?php
require_once('MsCommon.inc');
2017-05-04 01:00:31 +02:00
function simpleQuery()
2017-05-04 01:00:31 +02:00
{
$testName = "Statement - Simple Query";
startTest($testName);
setup();
$tableName = 'TC31test';
2017-05-04 01:00:31 +02:00
$conn1 = AE\connect();
2017-05-04 01:00:31 +02:00
// just create an empty table
2017-10-26 19:48:36 +02:00
$columns = array(new AE\ColumnMeta('int', 'dummyColumn'));
AE\createTable($conn1, $tableName, $columns);
2017-05-04 01:00:31 +02:00
trace("Executing SELECT query on $tableName ...");
2017-10-26 19:48:36 +02:00
$stmt1 = AE\selectFromTable($conn1, $tableName);
$rows = rowCount($stmt1);
2017-05-04 01:00:31 +02:00
sqlsrv_free_stmt($stmt1);
trace(" $rows rows retrieved.\n");
2017-05-04 01:00:31 +02:00
2017-10-26 19:48:36 +02:00
dropTable($conn1, $tableName);
if ($rows > 0) {
2017-05-04 01:00:31 +02:00
die("Table $tableName, expected to be empty, has $rows rows.");
}
sqlsrv_close($conn1);
endTest($testName);
2017-05-04 01:00:31 +02:00
}
try {
simpleQuery();
} catch (Exception $e) {
echo $e->getMessage();
2017-05-04 01:00:31 +02:00
}
?>
--EXPECT--
Test "Statement - Simple Query" completed successfully.