Annotation of embedaddon/php/ext/mysql/tests/connect.inc, revision 1.1
1.1 ! misho 1: <?php
! 2: if (!function_exists('sys_get_temp_dir')) {
! 3: function sys_get_temp_dir() {
! 4:
! 5: if (!empty($_ENV['TMP']))
! 6: return realpath( $_ENV['TMP'] );
! 7: if (!empty($_ENV['TMPDIR']))
! 8: return realpath( $_ENV['TMPDIR'] );
! 9: if (!empty($_ENV['TEMP']))
! 10: return realpath( $_ENV['TEMP'] );
! 11:
! 12: $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
! 13: if ($temp_file) {
! 14: $temp_dir = realpath(dirname($temp_file));
! 15: unlink($temp_file);
! 16: return $temp_dir;
! 17: }
! 18: return FALSE;
! 19: }
! 20: }
! 21:
! 22: if (!function_exists('my_mysql_connect')) {
! 23: /* wrapper to simplify test porting */
! 24: function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL, $persistent = false) {
! 25: global $connect_flags;
! 26:
! 27: $flags = ($flags === NULL) ? $connect_flags : $flags;
! 28:
! 29: if ($socket)
! 30: $host = sprintf("%s:%s", $host, $socket);
! 31: else if ($port)
! 32: $host = sprintf("%s:%s", $host, $port);
! 33:
! 34: if ($persistent) {
! 35: $link = mysql_pconnect($host, $user, $passwd, $flags);
! 36: } else {
! 37: $link = mysql_connect($host, $user, $passwd, true, $flags);
! 38: }
! 39:
! 40: if (!$link) {
! 41: printf("[000-a] Cannot connect using host '%s', user '%s', password '****', persistent = %d, [%d] %s\n",
! 42: $host, $user, ($persistent) ? 1 : 0,
! 43: mysql_errno(), mysql_error());
! 44: return false;
! 45: }
! 46:
! 47: if (!mysql_select_db($db, $link)) {
! 48: printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link));
! 49: return false;
! 50: }
! 51:
! 52: return $link;
! 53: }
! 54: } else {
! 55: printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
! 56: }
! 57:
! 58: /*
! 59: Default values are "localhost", "root", database "test" and empty password.
! 60: Change the MYSQL_TEST_* environment values if you want to use another configuration.
! 61: */
! 62:
! 63: $host = getenv("MYSQL_TEST_HOST") ? getenv("MYSQL_TEST_HOST") : "localhost";
! 64: $port = getenv("MYSQL_TEST_PORT") ? getenv("MYSQL_TEST_PORT") : 3306;
! 65: $user = getenv("MYSQL_TEST_USER") ? getenv("MYSQL_TEST_USER") : "root";
! 66: $passwd = getenv("MYSQL_TEST_PASSWD") ? getenv("MYSQL_TEST_PASSWD") : "";
! 67:
! 68: $db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test";
! 69: $engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
! 70: $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
! 71: $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
! 72: $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
! 73: if ($socket) {
! 74: ini_set('mysql.default_socket', $socket);
! 75: }
! 76: /* Development setting: test experimal features and/or feature requests that never worked before? */
! 77: $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
! 78: ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
! 79: false;
! 80:
! 81: $IS_MYSQLND = stristr(mysql_get_client_info(), "mysqlnd");
! 82: ?>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>