1--TEST-- 2odbc_connect(): Basic test for odbc_connect(). (When not using a DSN alias) 3--EXTENSIONS-- 4odbc 5--SKIPIF-- 6<?php 7include 'config.inc'; 8if (strpos($dsn, '=') === false) { 9 die('skip uses a DSN alias'); 10} 11include 'skipif.inc'; 12?> 13--XLEAK-- 14A bug in msodbcsql causes a memory leak when reconnecting after closing. See GH-12306 15--FILE-- 16<?php 17 18include 'config.inc'; 19$dsn = str_replace(";uid={$user};pwd={$pass}", '', $dsn); 20 21echo "dsn without credentials / correct user / correct password\n"; 22$conn = odbc_connect($dsn, $user, $pass); 23echo $conn ? "Connected.\n\n" : ""; 24if ($conn) odbc_close($conn); 25 26echo "dsn with correct user / incorrect user / correct password\n"; 27$conn = odbc_connect("{$dsn};uid={$user}", 'hoge', $pass); 28echo $conn ? "Connected.\n\n" : ""; 29if ($conn) odbc_close($conn); 30 31echo "dsn with correct password / correct user / incorrect password\n"; 32$conn = odbc_connect("{$dsn};PWD={$pass}", $user, 'fuga'); 33echo $conn ? "Connected.\n\n" : ""; 34if ($conn) odbc_close($conn); 35 36echo "dsn with correct credentials / incorrect user / incorrect password\n"; 37$conn = odbc_connect("{$dsn};Uid={$user};pwD={$pass}", 'hoge', 'fuga'); 38echo $conn ? "Connected.\n\n" : ""; 39if ($conn) odbc_close($conn); 40 41echo "dsn with correct credentials / null user / null password\n"; 42$conn = odbc_connect("{$dsn};Uid={$user};pwD={$pass}", null, null); 43echo $conn ? "Connected.\n\n" : ""; 44if ($conn) odbc_close($conn); 45 46echo "dsn with correct credentials / not set user / not set password\n"; 47$conn = odbc_connect("{$dsn};Uid={$user};pwD={$pass}"); 48echo $conn ? "Connected.\n" : ""; 49if ($conn) odbc_close($conn); 50?> 51--EXPECT-- 52dsn without credentials / correct user / correct password 53Connected. 54 55dsn with correct user / incorrect user / correct password 56Connected. 57 58dsn with correct password / correct user / incorrect password 59Connected. 60 61dsn with correct credentials / incorrect user / incorrect password 62Connected. 63 64dsn with correct credentials / null user / null password 65Connected. 66 67dsn with correct credentials / not set user / not set password 68Connected. 69