当前位置: 首页>>代码示例>>PHP>>正文


PHP my_mysqli_connect函数代码示例

本文整理汇总了PHP中my_mysqli_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP my_mysqli_connect函数的具体用法?PHP my_mysqli_connect怎么用?PHP my_mysqli_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了my_mysqli_connect函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 public function connect()
 {
     require_once "connect.inc";
     $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
     var_dump($link);
     $link = mysqli_init();
     /* @ is to suppress 'Property access is not allowed yet' */
     @var_dump($link);
     $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
     $mysql->query("DROP TABLE IF EXISTS test_bug34810_table_1");
     $mysql->query("CREATE TABLE test_bug34810_table_1 (a int not null)");
     $mysql->query("SET sql_mode=''");
     $mysql->query("INSERT INTO test_bug34810_table_1 VALUES (1),(2),(NULL)");
     $warning = $mysql->get_warnings();
     if (!$warning) {
         printf("[001] No warning!\n");
     }
     if ($warning->errno == 1048 || $warning->errno == 1253) {
         /* 1048 - Column 'a' cannot be null, 1263 - Data truncated; NULL supplied to NOT NULL column 'a' at row */
         if ("HY000" != $warning->sqlstate) {
             printf("[003] Wrong sql state code: %s\n", $warning->sqlstate);
         }
         if ("" == $warning->message) {
             printf("[004] Message string must not be empty\n");
         }
     } else {
         printf("[002] Empty error message!\n");
         var_dump($warning);
     }
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:bug34810.php

示例2: get_connection

function get_connection()
{
    global $host, $user, $passwd, $db, $port, $socket;
    if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
        printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
    }
    return $link;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:8,代码来源:ext_mysqli_tests_mysqli_poll_reference.php

示例3: my_mysqli_connect

<?php

require_once "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_037_table_1");
mysqli_query($link, "CREATE TABLE test_037_table_1 (a int, b varchar(10)) ENGINE = " . $engine);
mysqli_query($link, "INSERT INTO test_037_table_1 VALUES (1, 'foo')");
$ir[] = mysqli_field_count($link);
mysqli_real_query($link, "SELECT * FROM test_037_table_1");
$ir[] = mysqli_field_count($link);
var_dump($ir);
mysqli_query($link, "DROP TABLE IF EXISTS test_037_table_1");
mysqli_close($link);
print "done!";
require_once "connect.inc";
if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_037_table_1")) {
    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:24,代码来源:037.php

示例4: printf

<?php

require_once "connect.inc";
if (!($link = my_mysqli_connect($host, 'shatest', 'shatest', $db, $port, $socket))) {
    printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, "shatest", $db, $port, $socket);
} else {
    if (!($res = $link->query("SELECT id FROM test WHERE id = 1"))) {
        printf("[002] [%d] %s\n", $link->errno, $link->error);
    }
    if (!($row = mysqli_fetch_assoc($res))) {
        printf("[003] [%d] %s\n", $link->errno, $link->error);
    }
    if ($row['id'] != 1) {
        printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']);
    }
    $res->close();
    $link->close();
}
print "done!";
$test_table_name = 'test_mysqli_pam_sha256_table_1';
require_once "clean_table.inc";
$link->query('DROP USER shatest');
$link->query('DROP USER shatest@localhost');
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:mysqli_pam_sha256.php

示例5: printf

if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
    printf("[005] Cannot connect [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
} else {
    $link->query("SELECT id FROM test WHERE id = 1");
    printf("[006] Connect allowed, query fail, [%d] %s\n", $link->errno, $link->error);
    $link->close();
}
/* allow connect, fix pw */
$link = mysqli_init();
$link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
    printf("[007] Cannot connect [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
} else {
    $link->query("SET PASSWORD=PASSWORD('expiretest')");
    printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error);
    if ($res = $link->query("SELECT id FROM test WHERE id = 1")) {
        var_dump($res->fetch_assoc());
    }
    $link->close();
}
/* check login */
if (!($link = my_mysqli_connect($host, 'expiretest', "expiretest", $db, $port, $socket))) {
    printf("[001] Cannot connect [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
} else {
    $link->query("SELECT id FROM test WHERE id = 1");
    if ($res = $link->query("SELECT id FROM test WHERE id = 1")) {
        var_dump($res->fetch_assoc());
    }
    $link->close();
}
print "done!";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_expire_password.php

示例6: my_mysqli_connect

<?php

require_once "connect.inc";
$test = "";
/*** test mysqli_connect localhost:port ***/
$link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
$test .= $link ? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect ***/
$link = mysqli_init();
$test .= my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) ? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect with db ***/
$link = mysqli_init();
$test .= my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket) ? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect with port ***/
$link = mysqli_init();
$test .= my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket) ? "1" : "0";
mysqli_close($link);
/* temporary addition for Kent's setup, Win32 box */
for ($i = 0; $i < 10; $i++) {
    if (!($link = mysqli_init())) {
        printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
    }
    if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
        printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
    }
    mysqli_close($link);
}
/*** test mysqli_real_connect compressed ***/
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:001.php

示例7: my_mysqli_connect

<?php

require_once "connect.inc";
$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = $mysqli->query('select 1');
$result->close();
echo $result->num_rows;
$mysqli->close();
echo $result->num_rows;
echo "Done\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:bug36420.php

示例8: printf

    printf("[009] select_db should have failed\n");
}
// mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it
// Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would
// not have been set. If that would be the case, the test would be broken.
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_multi_query($link, "BAR; FOO;");
mysqli_query($link, "FOO");
mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db);
mysqli_kill($link, -1);
mysqli_real_query($link, "FOO");
mysqli_select_db($link, "Oh lord, let this be an unknown database name");
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_report(MYSQLI_REPORT_STRICT);
try {
    if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) {
        printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket);
    }
    mysqli_close($link);
} catch (mysqli_sql_exception $e) {
    printf("[011] %s\n", $e->getMessage());
}
try {
    if (!($link = mysqli_init())) {
        printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
    }
    if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) {
        printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket);
    }
    mysqli_close($link);
} catch (mysqli_sql_exception $e) {
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_mysqli_tests_mysqli_report_wo_ps.php

示例9: printf

for ($i = 0; $i < $num; $i++) {
    if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
        printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
    }
    $connections[] = $link;
}
$left = $num;
while (count($connections) && $left > 0) {
    do {
        $index = mt_rand(0, $num);
    } while (!isset($connections[$index]) && $left > 0);
    if (mt_rand(0, 1) > 0) {
        $left--;
        mysqli_close($connections[$index]);
        unset($connections[$index]);
    } else {
        $left--;
        if (!($connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
            printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        }
    }
    flush();
}
while (count($connections)) {
    do {
        $index = mt_rand(0, $num);
    } while (!isset($connections[$index]));
    mysqli_close($connections[$index]);
    unset($connections[$index]);
}
print "done!";
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:mysqli_pconnect.php

示例10: my_mysqli_connect

<?php

include "connect.inc";
$link1 = my_mysqli_connect($host, $user, $passwd, null, $port, $socket);
mysqli_select_db($link1, $db);
$link1->query("SELECT 'test'", MYSQLI_ASYNC);
$all_links = array($link1);
$links = $errors = $reject = $all_links;
mysqli_poll($links, $errors, $reject, 1);
echo "links: ", sizeof($links), "\n";
echo "errors: ", sizeof($errors), "\n";
echo "reject: ", sizeof($reject), "\n";
echo "all_links: ", sizeof($all_links), "\n";
$link1->close();
开发者ID:gleamingthecube,项目名称:php,代码行数:14,代码来源:ext_mysqli_tests_bug47050.php

示例11: printf

}
if ($num_plinks_kill > $num_plinks) {
    printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill);
}
if (!($plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))) {
    printf("[012] Cannot connect using the new password, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
if (!($res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1'))) {
    printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n", mysqli_errno($plink), mysqli_error($plink));
}
if (!($row = mysqli_fetch_assoc($res))) {
    printf("[014] Cannot run fetch result, [%d] %s\n", mysqli_errno($plink), mysqli_error($plink));
}
mysqli_free_result($res);
var_dump($row);
if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) {
    printf("[015] Can open more persistent connections than allowed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
    var_dump(mysqli_get_links_stats());
}
ob_start();
phpinfo();
$phpinfo = strip_tags(ob_get_contents());
ob_end_clean();
$phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500);
if (!preg_match('@Active Persistent Links\\s+=>\\s+(\\d+)@ismU', $phpinfo, $matches)) {
    printf("[016] Cannot get # of active persistent links from phpinfo()\n");
}
$num_plinks = $matches[1];
if ($num_plinks > (int) ini_get('mysqli.max_persistent')) {
    printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'), $num_plinks);
}
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_pconn_max_links.php


注:本文中的my_mysqli_connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。