• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysqli_stmt_errno函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mysqli_fetch_array_large

function mysqli_fetch_array_large($offset, $link, $package_size)
{
    /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
    $random_char = str_repeat('a', 255);
    $sql = "INSERT INTO test(label) VALUES ";
    while (strlen($sql) < $package_size - 259) {
        $sql .= sprintf("('%s'), ", $random_char);
    }
    $sql = substr($sql, 0, -2);
    $len = strlen($sql);
    assert($len < $package_size);
    if (!@mysqli_query($link, $sql)) {
        if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet')) {
            /*
            	myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
            	libmysql -[2006] MySQL server has gone away
            */
            return false;
        }
        printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    /* buffered result set - let's hope we do not run into PHP memory limit... */
    if (!($res = mysqli_query($link, "SELECT id, label FROM test"))) {
        printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    while ($row = mysqli_fetch_assoc($res)) {
        if ($row['label'] != $random_char) {
            printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
            return false;
        }
    }
    mysqli_free_result($res);
    if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test"))) {
        printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    /* unbuffered result set */
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
        return false;
    }
    $id = $label = NULL;
    if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
        printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
        return false;
    }
    while (mysqli_stmt_fetch($stmt)) {
        if ($label != $random_char) {
            printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
    }
    mysqli_stmt_free_result($stmt);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:58,代码来源:ext_mysqli_tests_mysqli_fetch_array_large.php


示例2: bind_twice

function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset)
{
    if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_bind_param_type_juggling_table_1")) {
        printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    mysqli_autocommit($link, true);
    $sql = sprintf("CREATE TABLE test_mysqli_stmt_bind_param_type_juggling_table_1(col1 %s, col2 %s) ENGINE=%s", $sql_type1, $sql_type2, $engine);
    if (!mysqli_query($link, $sql)) {
        printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_stmt_prepare($stmt, "INSERT INTO test_mysqli_stmt_bind_param_type_juggling_table_1(col1, col2) VALUES (?, ?)")) {
        printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) {
        printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value2)) {
        printf("[%03d + 7] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d + 8] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    mysqli_stmt_close($stmt);
    if (!($res = mysqli_query($link, "SELECT col1, col2 FROM test_mysqli_stmt_bind_param_type_juggling_table_1"))) {
        printf("[%03d + 9] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (2 !== ($tmp = mysqli_num_rows($res))) {
        printf("[%03d + 10] Expecting 2 rows, got %d rows [%d] %s\n", $offset, $tmp, mysqli_errno($link), mysqli_error($link));
    }
    $row = mysqli_fetch_assoc($res);
    if ($row['col1'] != $bind_value1 || $row['col2'] != $bind_value1) {
        printf("[%03d + 11] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value1, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link));
        return false;
    }
    $row = mysqli_fetch_assoc($res);
    if ($row['col1'] != $bind_value1 || $row['col2'] != $bind_value2) {
        printf("[%03d + 12] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value2, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link));
        return false;
    }
    mysqli_free_result($res);
    return true;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:57,代码来源:mysqli_stmt_bind_param_type_juggling.php


示例3: mysqli_update

function mysqli_update($db, $sql)
{
    $stmt = call_user_func_array('mysqli_interpolate', func_get_args());
    if (!mysqli_stmt_execute($stmt)) {
        throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
    }
    $affected = mysqli_stmt_affected_rows($stmt);
    mysqli_stmt_close($stmt);
    return (int) $affected;
}
开发者ID:s-melnikov,项目名称:booking,代码行数:10,代码来源:functions.php


示例4: func_test_mysqli_stmt_param_count_table_1_mysqli_stmt_param_count

function func_test_mysqli_stmt_param_count_table_1_mysqli_stmt_param_count($stmt, $query, $expected, $offset)
{
    if (!mysqli_stmt_prepare($stmt, $query)) {
        printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt));
        return false;
    }
    if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) {
        printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp);
    }
    return true;
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:11,代码来源:mysqli_stmt_param_count.php


示例5: test_format

function test_format($link, $format, $from, $order_by, $expected, $offset)
{
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%03d] Cannot create PS, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if ($order_by) {
        $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
    } else {
        $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
    }
    if (!mysqli_stmt_prepare($stmt, $sql)) {
        printf("[%03d] Cannot prepare PS, [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d] Cannot execute PS, [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_store_result($stmt)) {
        printf("[%03d] Cannot store result set, [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!is_array($expected)) {
        $result = null;
        if (!mysqli_stmt_bind_result($stmt, $result)) {
            printf("[%03d] Cannot bind result, [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        if (!mysqli_stmt_fetch($stmt)) {
            printf("[%03d] Cannot fetch result,, [%d] %s\n", $offset + 5, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        if ($result !== $expected) {
            printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n", $offset + 6, gettype($expected), $expected, gettype($result), $result, $format, $sql);
        }
    } else {
        $order_by_col = $result = null;
        if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
            printf("[%03d] Cannot bind result, [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        reset($expected);
        while ((list($k, $v) = each($expected)) && mysqli_stmt_fetch($stmt)) {
            if ($result !== $v) {
                printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", $offset + 8, $k, gettype($v), $v, gettype($result), $result, $order_by_col, $format, $sql);
            }
        }
    }
    mysqli_stmt_free_result($stmt);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:53,代码来源:ext_mysqli_tests_mysqli_stmt_bind_result_format.php


示例6: mysqli_interpolate

function mysqli_interpolate($db, string $sql, ...$args) : mysqli_stmt
{
    $argn = count($args);
    $stmt = mysqli_prepare($db, $sql);
    if ($stmt === false) {
        throw new mysqli_sql_exception(mysqli_error($db), mysqli_errno($db));
    }
    if ($argn) {
        $syms = str_repeat('s', $argn);
        if (false === mysqli_stmt_bind_param($stmt, $syms, ...$args)) {
            throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
        }
    }
    return $stmt;
}
开发者ID:noodlehaus,项目名称:mysqli_etc,代码行数:15,代码来源:mysqli_etc.php


示例7: zerofill

function zerofill($offset, $link, $datatype, $insert = 1)
{
    mysqli_query($link, 'ALTER TABLE test_mysqli_stmt_bind_result_zerofill_table_1 DROP zero');
    $sql = sprintf('ALTER TABLE test_mysqli_stmt_bind_result_zerofill_table_1 ADD zero %s UNSIGNED ZEROFILL', $datatype);
    if (!mysqli_query($link, $sql)) {
        // no worries - server might not support it
        return true;
    }
    if (!mysqli_query($link, sprintf('UPDATE test_mysqli_stmt_bind_result_zerofill_table_1 SET zero = %s', $insert))) {
        printf("[%03d] UPDATE failed, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!($stmt = mysqli_prepare($link, 'SELECT zero FROM test_mysqli_stmt_bind_result_zerofill_table_1 LIMIT 1'))) {
        printf("[%03d] SELECT failed, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    $result = null;
    if (!mysqli_stmt_bind_result($stmt, $result)) {
        printf("[%03d] Bind failed, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) {
        printf("[%03d] Execute or fetch failed, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    $res = mysqli_stmt_result_metadata($stmt);
    $meta = mysqli_fetch_fields($res);
    mysqli_stmt_free_result($stmt);
    $meta = $meta[0];
    $length = $meta->length;
    if ($length > strlen($insert)) {
        $expected = str_repeat('0', $length - strlen($insert));
        $expected .= $insert;
        if ($expected !== $result) {
            printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $result);
            return false;
        }
    } else {
        if ($length <= 1) {
            printf("[%03d] Length reported is too small to run test\n", $offset);
            return false;
        }
    }
    return true;
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:45,代码来源:mysqli_stmt_bind_result_zerofill.php


示例8: func_test_mysqli_stmt_num_rows

function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset)
{
    if (!mysqli_stmt_prepare($stmt, $query)) {
        printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d] [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if (!mysqli_stmt_store_result($stmt)) {
        printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    if ($expected !== ($tmp = mysqli_stmt_num_rows($stmt))) {
        printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp);
    }
    mysqli_stmt_free_result($stmt);
    return true;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:20,代码来源:ext_mysqli_tests_mysqli_stmt_num_rows.php


示例9: printf

if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test_mysqli_stmt_bind_param_call_user_func_table_1 WHERE id = ?')) {
    printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
$id = 1;
$params = array(0 => 'i', 1 => &$id);
if (!call_user_func_array(array($stmt, 'bind_param'), $params)) {
    printf("[047] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!mysqli_stmt_execute($stmt)) {
    printf("[048] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt));
}
mysqli_stmt_close($stmt);
if (!($stmt = mysqli_stmt_init($link))) {
    printf("[049] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test_mysqli_stmt_bind_param_call_user_func_table_1 WHERE id = ?')) {
    printf("[050] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
$types = 'i';
$id = 1;
$params = array(0 => $stmt, 1 => 'i', 2 => &$id);
if (!call_user_func_array('mysqli_stmt_bind_param', $params)) {
    printf("[051] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!mysqli_stmt_execute($stmt)) {
    printf("[052] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt));
}
print "done!";
error_reporting(0);
$test_table_name = 'test_mysqli_stmt_bind_param_call_user_func_table_1';
require_once "clean_table.inc";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:mysqli_stmt_bind_param_call_user_func.php


示例10: printf

if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25), OUT ver_out VARCHAR(25)) BEGIN SELECT ver_in INTO ver_out; END;')) {
    if (!($stmt = mysqli_prepare($link, 'CALL p(?, ?)'))) {
        printf("[005] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
    }
    $ver_in = 'myversion';
    $ver_out = '';
    if (!mysqli_stmt_bind_param($stmt, 'ss', $ver_in, $ver_out)) {
        printf("[006] Cannot bind parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[007] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
    }
    printf("[008] More results: %s\n", mysqli_more_results($link) ? "yes" : "no");
    printf("[009] Next results: %s\n", mysqli_next_result($link) ? "yes" : "no");
    if (!mysqli_stmt_bind_result($stmt, $ver_out) || !mysqli_stmt_fetch($stmt)) {
        printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
    }
    if ("myversion" !== $ver_out) {
        printf("[011] Results seem wrong got '%s'\n", $ver_out);
    }
    if (!mysqli_stmt_close($stmt)) {
        printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
    }
    if (!($res = $link->query("SELECT 1"))) {
        printf("[013] [%d] %s\n", $link->errno, $link->error);
    }
} else {
    printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
print "done!";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_stmt_execute_stored_proc_out.php


示例11: printf

if (!($stmt_buf = mysqli_stmt_init($link_buf))) {
    printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test_mysqli_stmt_store_result_table_1 ORDER BY id") || !mysqli_stmt_execute($stmt_buf)) {
    printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf));
}
$id = $label = $id_buf = $label_buf = null;
if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
    printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) {
    printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf));
}
while (mysqli_stmt_fetch($stmt)) {
    if (!mysqli_stmt_fetch($stmt_buf)) {
        printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf));
    }
    if ($id !== $id_buf) {
        printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", $id, gettype($id), $id_buf, gettype($id_buf));
    }
    if ($label !== $label_buf) {
        printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", $label, gettype($label), $label_buf, gettype($label_buf));
    }
}
mysqli_stmt_close($stmt);
mysqli_stmt_close($stmt_buf);
mysqli_close($link);
mysqli_close($link_buf);
print "done!";
error_reporting(0);
$test_table_name = 'test_mysqli_stmt_store_result_table_1';
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:mysqli_stmt_store_result.php


示例12: printf

 if (!mysqli_stmt_execute($stmt_ins)) {
     printf("[008 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins));
     break;
 }
 $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %s", $value);
 if (!mysqli_stmt_prepare($stmt_sel, $sql) || !mysqli_stmt_execute($stmt_sel)) {
     printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel));
     break;
 }
 $row = array('id' => -1, '_bin' => -1, 'bit_value' => -1, '_bit_value0' => -1, 'bit_null' => -1);
 if (!mysqli_stmt_bind_result($stmt_sel, $row['id'], $row['_bin'], $row['bit_value'], $row['_bit_value0'], $row['bit_null'])) {
     printf("[010 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel));
     break;
 }
 if (!($ret = mysqli_stmt_fetch($stmt_sel))) {
     printf("[011 - %d] mysqli_stmt_fetch() has failed for %d bits - ret = %s/%s, [%d] %s, [%d] %s\n", $bits, $bits, gettype($ret), $ret, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel), mysqli_errno($link_sel), mysqli_errno($link_sel));
     break;
 }
 if ($value != $row['id'] || $bin != $row['_bin'] && $bin2 != $row['_bin']) {
     debug_zval_dump($row);
     printf("[012 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2);
     break;
 }
 if ($value != $row['bit_value']) {
     debug_zval_dump($row);
     printf("[013 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']);
     break;
 }
 if (null !== $row['bit_null']) {
     debug_zval_dump($row);
     printf("[014 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']);
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_stmt_bind_result_bit.php


示例13: executeNonQuery

 public function executeNonQuery($sql, $argv = NULL)
 {
     //Logger::trace("MysqlDao.executeNonQuery executed", LOG_LEVEL_NOTICE);
     $affected = 0;
     // 校验参数有效性
     $lowstr = strtolower($sql);
     if (strtolower(substr($lowstr, 0, 6)) === "select") {
         echo "Invalid query SQL statement.";
     }
     //echo $sql;
     // 创建数据库连接(如果需要)
     $connected = $this->connected();
     $conn = $connected ? $this->conn : $this->connect(FALSE);
     // 将默认字符集设置为utf8
     mysqli_query($conn, "set names 'utf8'");
     mysqli_query($conn, "set character set 'utf8'");
     // 执行SQL语句
     $stmt = mysqli_prepare($conn, $sql);
     if (mysqli_errno($conn)) {
         $errno = mysqli_errno($conn);
         $error = "MYSQL ERROR #" . $errno . " : " . mysqli_error($conn);
         echo $error;
     }
     // 根据参数的个数动态生成参数绑定语句
     if (isset($argv) && count($argv) > 0) {
         $bind_param_cmd = "mysqli_stmt_bind_param(\$stmt, ";
         $paramstr = "";
         $bindstr = "";
         $holdstr = "";
         $i = 0;
         foreach ($argv as $arg) {
             $paramstr .= "\$invar{$i}, ";
             $bindstr .= "\$invar{$i} = \$argv[{$i}]; ";
             $holdstr .= "s";
             $i++;
         }
         $bind_param_cmd = "mysqli_stmt_bind_param(\$stmt, \"{$holdstr}\", " . substr($paramstr, 0, strlen($paramstr) - 2) . "); ";
         $bind_param_cmd .= $bindstr;
         eval($bind_param_cmd);
         //将字符串中的变量代入
     }
     // 执行SQL语句
     mysqli_stmt_execute($stmt);
     if (mysqli_stmt_errno($stmt)) {
         $errno = mysqli_stmt_errno($stmt);
         $error = "MYSQL ERROR #" . $errno . " : " . mysqli_stmt_error($stmt);
         echo $error;
     }
     $this->insert_id = mysqli_stmt_insert_id($stmt);
     //数据库操作数据id
     //echo $this->insert_id;
     $affected = mysqli_stmt_affected_rows($stmt);
     mysqli_stmt_close($stmt);
     // 关闭数据库连接(如果需要)
     if (!$connected) {
         $this->disconnect($conn);
     }
     return $affected;
 }
开发者ID:dalinhuang,项目名称:hnaust-1,代码行数:59,代码来源:mysqldao.php


示例14: executeQueryA

 public function executeQueryA($sql, $argv = NULL, $pagesize = 0, $pageno = 0)
 {
     //Logger::trace("MysqlDao.executeQuery executed", LOG_LEVEL_NOTICE);
     if ($pagesize < 0) {
         $pagesize = 0;
     }
     if ($pageno < 0) {
         $pageno = 0;
     }
     $lowstr = strtolower($sql);
     if (!(strtolower(substr($lowstr, 0, 6)) === "select")) {
         throw new DaoException("Invalid query SQL statement.");
     }
     $pos = strpos($lowstr, "from");
     if (!strpos($lowstr, "from")) {
         //Logger::trace("Invalid query SQL statement.", LOG_LEVEL_ERROR);
         //Logger::debug("sql = $sql, argv = $argv");
         throw new DaoException("Invalid query SQL statement.");
     }
     $colstr = substr($lowstr, 6, $pos - 6);
     $pos = 0;
     $colcount = 0;
     while (!($pos === false)) {
         $pos = strpos($colstr, ",", $pos + 1);
         $colcount++;
     }
     $connected = $this->connected();
     $conn = $connected ? $this->conn : $this->connect(FALSE);
     mysqli_query($conn, "set names 'utf8'");
     $allrow = array();
     $stmt = mysqli_prepare($conn, $sql);
     if (mysqli_errno($conn)) {
         $errno = mysqli_errno($conn);
         $error = "MYSQL ERROR #" . $errno . " : " . mysqli_error($conn);
         throw new DaoException($error, $errno);
     }
     //Logger::trace("sql = " . $sql, LOG_LEVEL_VERBOSE);
     if (isset($argv) && count($argv) > 0) {
         $bind_param_cmd = "mysqli_stmt_bind_param(\$stmt, ";
         $paramstr = "";
         $bindstr = "";
         $holdstr = "";
         $i = 0;
         foreach ($argv as $arg) {
             $paramstr .= "\$invar{$i}, ";
             $bindstr .= "\$invar{$i} = \$argv[{$i}]; ";
             $holdstr .= "s";
             $i++;
         }
         $bind_param_cmd = "mysqli_stmt_bind_param(\$stmt, \"{$holdstr}\", " . substr($paramstr, 0, strlen($paramstr) - 2) . "); ";
         $bind_param_cmd .= $bindstr;
         //Logger::trace("bind parameter: " . $bind_param_cmd, LOG_LEVEL_VERBOSE);
         eval($bind_param_cmd);
     }
     mysqli_stmt_execute($stmt);
     if (mysqli_stmt_errno($stmt)) {
         $errno = mysqli_stmt_errno($stmt);
         $error = "MYSQL ERROR #" . $errno . " : " . mysqli_stmt_error($stmt);
         //Logger::trace($error, LOG_LEVEL_ERROR);
         //Logger::debug("sql = $sql ". ($argv));
         throw new DaoException($error, $errno);
     }
     //��ý���Ԫ��� //
     /*&�����   ��j���� �Խ����ֶ�Ϊ����*/
     $data = mysqli_stmt_result_metadata($stmt);
     $fields = array();
     $out = array();
     $fields[0] = $stmt;
     $count = 1;
     while ($field = mysqli_fetch_field($data)) {
         $fields[$count] =& $out[$field->name];
         $count++;
     }
     call_user_func_array(mysqli_stmt_bind_result, $fields);
     //����
     mysqli_stmt_store_result($stmt);
     //��ҳ
     if ($pagesize > 0) {
         mysqli_stmt_data_seek($stmt, $pagesize * $pageno);
     }
     $cnt = 1;
     while (mysqli_stmt_fetch($stmt)) {
         /*���$row���ø�ֵֻ�����һ���¼������
         			�������ѭ�������ݵĸ�ֵ
         		*/
         foreach ($out as $key => $value) {
             $row_tmb[$key] = $value;
         }
         $allrow[] = $row_tmb;
         if ($pagesize > 0) {
             if (++$cnt > $pagesize) {
                 break;
             }
         }
     }
     mysqli_stmt_close($stmt);
     if (!$connected) {
         $this->disconnect($conn);
     }
     return $allrow;
//.........这里部分代码省略.........
开发者ID:dalinhuang,项目名称:hnaust-1,代码行数:101,代码来源:mysqldao.class.php


示例15: func_mysqli_stmt_get_result

function func_mysqli_stmt_get_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null)
{
    if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_get_result_types_table_1")) {
        printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_query($link, sprintf("CREATE TABLE test_mysqli_stmt_get_result_types_table_1(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
        // don't bail - column type might not be supported by the server, ignore this
        return false;
    }
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_stmt_prepare($stmt, "INSERT INTO test_mysqli_stmt_get_result_types_table_1(id, label) VALUES (?, ?)")) {
        printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        return false;
    }
    $id = null;
    if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) {
        printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    for ($id = 1; $id < 4; $id++) {
        if (!mysqli_stmt_execute($stmt)) {
            printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            mysqli_stmt_close($stmt);
            return false;
        }
    }
    mysqli_stmt_close($stmt);
    $stmt = mysqli_stmt_init($link);
    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test_mysqli_stmt_get_result_types_table_1")) {
        printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    $result = mysqli_stmt_result_metadata($stmt);
    if (!($res = mysqli_stmt_get_result($stmt))) {
        printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    $num = 0;
    $fields = mysqli_fetch_fields($result);
    while ($row = mysqli_fetch_assoc($res)) {
        $bind_res =& $row['label'];
        if (!gettype($bind_res) == 'unicode') {
            if ($bind_res !== $bind_value && (!$type_hint || $type_hint !== gettype($bind_res))) {
                printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", $offset + 10, $num, gettype($bind_value), $bind_value, $type_hint, gettype($bind_res), $bind_res);
                mysqli_free_result($res);
                mysqli_stmt_close($stmt);
                return false;
            }
        }
        $num++;
    }
    if ($num != 3) {
        printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
        mysqli_free_result($res);
        mysqli_stmt_close($stmt);
        return false;
    }
    mysqli_free_result($res);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:73,代码来源:mysqli_stmt_get_result_types.php


示例16: func_mysqli_stmt_get_result_geom

function func_mysqli_stmt_get_result_geom($link, $engine, $sql_type, $bind_value, $offset)
{
    if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_get_result_geom_table_1")) {
        printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_query($link, sprintf("CREATE TABLE test_mysqli_stmt_get_result_geom_table_1(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
        // don't bail - column type might not be supported by the server, ignore this
        return false;
    }
    for ($id = 1; $id < 4; $id++) {
        $sql = sprintf("INSERT INTO test_mysqli_stmt_get_result_geom_table_1(id, label) VALUES (%d, %s)", $id, $bind_value);
        if (!mysqli_query($link, $sql)) {
            printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
        }
    }
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test_mysqli_stmt_get_result_geom_table_1")) {
        printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    if (!($res = mysqli_stmt_get_result($stmt))) {
        printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    $result = mysqli_stmt_result_metadata($stmt);
    $fields = mysqli_fetch_fields($result);
    if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
        printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
    }
    $num = 0;
    while ($row = mysqli_fetch_assoc($res)) {
        $bind_res =& $row['label'];
        if (!($stmt2 = mysqli_stmt_init($link))) {
            printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test_mysqli_stmt_get_result_geom_table_1(id, label) VALUES (?, ?)")) {
            printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        $id = $row['id'] + 10;
        if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) {
            printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        if (!mysqli_stmt_execute($stmt2)) {
            printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        mysqli_stmt_close($stmt2);
        if (!($res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test_mysqli_stmt_get_result_geom_table_1 WHERE id = %d", $row['id'] + 10)))) {
            printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if (!($row_normal = mysqli_fetch_assoc($res_normal))) {
            printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if ($row_normal['label'] != $bind_res) {
            printf("[%04d] PS and non-PS return different data.\n", $offset + 17);
            return false;
        }
        mysqli_free_result($res_normal);
        $num++;
    }
    if ($num != 3) {
        printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
        mysqli_free_result($res);
        mysqli_stmt_close($stmt);
        return false;
    }
    mysqli_free_result($res);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:86,代码来源:mysqli_stmt_get_result_geom.php


示例17: session_start

<?php

session_start();
// Establish connection to database
require_once 'soluMySQLConnect.php';
$firstName = $_POST['firstname'];
$lastName = $_POST['lastname'];
$userName = $_POST['username'];
$filteredUserName = preg_replace("/[^a-zA-Z0-9]+/", "", $userName);
$password = $_POST['password'];
$filteredPassword = preg_replace("/[^a-zA-Z0-9]+/", "", $password);
$encrypted_password = md5($password);
// Redirect back to the specified page or go to the homepage if not specified.
$return_page = $_GET['next'] ?: '/index.php';
$statement = mysqli_prepare($dbc, "INSERT INTO accounts (First_Name, Last_Name, Username, Password) VALUES (?,?,?,?)");
mysqli_stmt_bind_param($statement, 'ssss', $firstName, $lastName, $userName, $encrypted_password);
mysqli_stmt_execute($statement);
if (mysqli_stmt_errno($statement)) {
    die('Error: ' . mysqli_connect_errno() . mysqli_connect_error() . PHP_EOL);
} else {
    echo 'Account has been created!<br>Redirecting back to home...';
    $_SESSION['loggedIn'] = true;
    $_SESSION['username'] = $userName;
    header("refresh: 0; {$return_page}");
}
mysqli_stmt_close($statement);
mysqli_close($dbc);
开发者ID:elarbee,项目名称:solu-buddy,代码行数:27,代码来源:soluRegistration.php


示例18: _set_stmt_error

 protected function _set_stmt_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = mysqli_stmt_sqlstate($this->_result);
     }
     $this->_set_error(mysqli_stmt_errno($this->_result), mysqli_stmt_error($this->_result), $state, $mode, $func);
 }
开发者ID:PHPcomaptibility,项目名称:PHPPDO,代码行数:7,代码来源:mysqli_statement.php


示例19: printf

    printf("%s\n", $var);
}
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($stmt));
foreach ($variables as $k => $var) {
    printf("%s\n", $var);
}
printf("\nMagic, magic properties:\n");
assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows);
printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows);
if (!$stmt->prepare("INSERT INTO test_mysqli_class_mysqli_stmt_interface_table_1(id, label) VALUES (100, 'z')") || !$stmt->execute()) {
    printf("[001] [%d] %s\n", $stmt->errno, $stmt->error);
}
assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows);
printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows);
assert(mysqli_stmt_errno($stmt) === $stmt->errno);
printf("stmt->errno = '%s'\n", $stmt->errno);
assert(mysqli_stmt_error($stmt) === $stmt->error);
printf("stmt->error = '%s'\n", $stmt->error);
assert(mysqli_stmt_error_list($stmt) === $stmt->error_list);
var_dump("stmt->error = ", $stmt->error_list);
assert(mysqli_stmt_field_count($stmt) === $stmt->field_count);
printf("stmt->field_count = '%s'\n", $stmt->field_count);
assert($stmt->id > 0);
printf("stmt->id = '%s'\n", $stmt->id);
assert(mysqli_stmt_insert_id($stmt) === $stmt->insert_id);
printf("stmt->insert_id = '%s'\n", $stmt->insert_id);
assert(mysqli_stmt_num_rows($stmt) === $stmt->num_rows);
printf("stmt->num_rows = '%s'\n", $stmt->num_rows);
assert(mysqli_stmt_param_count($stmt) === $stmt->param_count);
printf("stmt->param_count = '%s'\n", $stmt->param_count);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:mysqli_class_mysqli_stmt_interface.php


示例20: mysqli_get_client_stats_assert_gt


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysqli_stmt_error函数代码示例发布时间:2022-05-15
下一篇:
PHP mysqli_stmt_close函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap