php-src/ext/odbc/tests/odbc_free_result_001.phpt
Christoph M. Becker 0a9f552911
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ODBC test which may not properly clean up
2022-01-07 19:25:23 +01:00

57 lines
1.3 KiB
PHP

--TEST--
odbc_free_result(): Basic test
--EXTENSIONS--
odbc
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'CREATE DATABASE odbcTEST');
odbc_exec($conn, 'CREATE TABLE FOO (TEST INT NOT NULL)');
odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY (TEST)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (1)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (2)');
$res = odbc_exec($conn, 'SELECT * FROM FOO');
var_dump(odbc_fetch_row($res));
var_dump(odbc_result($res, 'test'));
var_dump(odbc_free_result($res));
try {
var_dump(odbc_free_result($conn));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(odbc_fetch_row($res));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(odbc_result($res, 'test'));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
?>
--CLEAN--
<?php
require 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'DROP TABLE FOO');
odbc_exec($conn, 'DROP DATABASE odbcTEST');
?>
--EXPECT--
bool(true)
string(1) "1"
bool(true)
odbc_free_result(): supplied resource is not a valid ODBC result resource
odbc_fetch_row(): supplied resource is not a valid ODBC result resource
odbc_result(): supplied resource is not a valid ODBC result resource