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


PHP mysqli_fetch_lengths函数代码示例

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


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

示例1: printf

 if (!($res = mysqli_store_result($link))) {
     printf("[012 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link));
     continue;
 }
 $num_rows = 0;
 while ($row = mysqli_fetch_array($res)) {
     $num_rows++;
     if ($row['num'] != $res_num) {
         printf("[013 - %d] Expecting %s got %s\n", $res_num, $res_num, $row['num']);
     }
     if ($row['somechar'] != "a") {
         printf("[014 - %d] Expecting a got %s\n", $res_num, $row['somechar']);
     }
     if (1 == $num_rows) {
         /* simple metadata check */
         if (!($lengths = mysqli_fetch_lengths($res))) {
             printf("[015 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link));
         }
         if (count($lengths) != 2) {
             printf("[016 - %d] Expecting 2 column lengths got %d [%d] %s\n", $res_num, count($lengths));
         }
         foreach ($lengths as $k => $length) {
             if ($length <= 0) {
                 printf("[017 - %d] Strange column lengths for column %d, got %d expecting any > 0\n", $res_num, $k, $length);
             }
         }
     }
 }
 if ($num_rows != 1) {
     printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows);
 }
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_multi_query.php

示例2: my_mysqli_connect

$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_047_table_1");
mysqli_query($link, "CREATE TABLE test_047_table_1 (foo int, bar varchar(10) character set latin1) ENGINE=" . $engine);
mysqli_query($link, "INSERT INTO test_047_table_1 VALUES (1, 'Zak'),(2, 'Greant')");
$stmt = mysqli_prepare($link, "SELECT * FROM test_047_table_1");
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_result_metadata($stmt);
echo "\n=== fetch_fields ===\n";
var_dump(mysqli_fetch_fields($result));
echo "\n=== fetch_field_direct ===\n";
var_dump(mysqli_fetch_field_direct($result, 0));
var_dump(mysqli_fetch_field_direct($result, 1));
echo "\n=== fetch_field ===\n";
while ($field = mysqli_fetch_field($result)) {
    var_dump($field);
}
print_r(mysqli_fetch_lengths($result));
mysqli_free_result($result);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_047_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_047_table_1")) {
    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:047.php

示例3: mysql_fetch_lengths

 function mysql_fetch_lengths($result)
 {
     if (!is_myresource($result, true)) {
         $msg = sprintf('expects parameter 1 to be mysql result object, %s given', gettype($result));
         trigger_error(mysql_trigger_msg($msg, current(debug_backtrace())), E_USER_WARNING);
         return false;
     }
     return mysqli_fetch_lengths($result);
 }
开发者ID:OOPS-ORG-PHP,项目名称:mysql-extension-wrapper,代码行数:9,代码来源:mysql-wrapper.php

示例4: var_dump

    var_dump(mysqli_fetch_lengths($res));
}
var_dump(mysqli_fetch_lengths($res));
if (!($res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))) {
    printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) {
    printf("[013] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link));
}
printf("Copy\n");
var_dump(mysqli_fetch_lengths($res));
$fields_copy = $res->fetch_fields();
while ($row = $res->fetch_assoc()) {
    var_dump(mysqli_fetch_lengths($res));
}
var_dump(mysqli_fetch_lengths($res));
/* There's no need for in-depth testing here. If you want in-depth switch mysqlnd
	globally to copy mode and run all the tests */
foreach ($fields as $k => $field_info) {
    if ($fields_copy[$k] != $field_info) {
        printf("[014] Metadata seems to differ, dumping\n");
        var_dump($field_info);
        var_dump($fields_copy[$k]);
    }
}
/* fetch all */
if (!($res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))) {
    printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) {
    printf("[016] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link));
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_store_result_copy.php

示例5: fetchOne

 public function fetchOne()
 {
     if ($this->usemysqli) {
         switch ($this->fetchMode) {
             case __ARRAY:
                 $result = mysqli_fetch_array($this->result);
                 break;
             case __ASSOCARRAY:
                 $result = mysqli_fetch_assoc($this->result);
                 break;
             case __FIELDDIRECT:
                 $result = mysqli_fetch_field_direct($this->result, $this->fetchFieldDirectFieldNr);
                 break;
             case __FIELD:
                 $result = mysqli_fetch_field($this->result);
                 break;
             case __FIELDS:
                 $result = mysqli_fetch_fields($this->result);
                 break;
             case __LENGTHS:
                 $result = mysqli_fetch_lengths($this->result);
                 break;
             case __OBJECT:
                 $result = mysqli_fetch_object($this->result);
                 break;
             case __ROW:
                 $result = mysqli_fetch_row($this->result);
                 break;
             default:
                 $result = null;
                 break;
         }
         return $result;
     } else {
         switch ($this->fetchMode) {
             case __ARRAY:
                 $result = mysql_fetch_array($this->result);
                 break;
             case __ASSOCARRAY:
                 $result = mysql_fetch_assoc($this->result);
                 break;
             case __FIELDDIRECT:
                 $result = NULL;
                 break;
             case __FIELD:
                 $result = mysql_fetch_field($this->result);
                 break;
             case __FIELDS:
                 $result = NULL;
                 break;
             case __LENGTHS:
                 $result = mysql_fetch_lengths($this->result);
                 break;
             case __OBJECT:
                 $result = mysql_fetch_object($this->result);
                 break;
             case __ROW:
                 $result = mysql_fetch_row($this->result);
                 break;
             default:
                 $result = null;
                 break;
         }
         return $result;
     }
 }
开发者ID:BackupTheBerlios,项目名称:alien-svn,代码行数:66,代码来源:result.php

示例6: mysql_fetch_lengths

 function mysql_fetch_lengths($result)
 {
     if (\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     return mysqli_fetch_lengths($result);
 }
开发者ID:gsomoza,项目名称:php7-mysql-shim,代码行数:9,代码来源:mysql.php

示例7: array_keys

$variables = array_keys(get_class_vars(get_class($mysqli_result)));
sort($variables);
foreach ($variables as $k => $var) {
    printf("%s\n", $var);
}
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($mysqli_result));
foreach ($variables as $k => $var) {
    printf("%s\n", $var);
}
printf("\nMagic, magic properties:\n");
assert(($tmp = mysqli_field_tell($res)) === $mysqli_result->current_field);
printf("mysqli_result->current_field = '%s'/%s ('%s'/%s)\n", $mysqli_result->current_field, gettype($mysqli_result->current_field), $tmp, gettype($tmp));
assert(($tmp = mysqli_field_count($link)) === $mysqli_result->field_count);
printf("mysqli_result->field_count = '%s'/%s ('%s'/%s)\n", $mysqli_result->field_count, gettype($mysqli_result->field_count), $tmp, gettype($tmp));
assert(($tmp = mysqli_fetch_lengths($res)) === $mysqli_result->lengths);
printf("mysqli_result->lengths -> '%s'/%s ('%s'/%s)\n", is_array($mysqli_result->lengths) ? implode(' ', $mysqli_result->lengths) : 'n/a', gettype($mysqli_result->lengths), is_array($tmp) ? implode(' ', $tmp) : 'n/a', gettype($tmp));
assert(($tmp = mysqli_num_rows($res)) === $mysqli_result->num_rows);
printf("mysqli_result->num_rows = '%s'/%s ('%s'/%s)\n", $mysqli_result->num_rows, gettype($mysqli_result->num_rows), $tmp, gettype($tmp));
assert(in_array($mysqli_result->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT)));
printf("mysqli_result->type = '%s'/%s\n", MYSQLI_STORE_RESULT == $mysqli_result->type ? 'store' : 'use', gettype($mysqli_result->type));
printf("\nAccess to undefined properties:\n");
printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown);
printf("\nConstructor:\n");
if (!is_object($res = new mysqli_result($link))) {
    printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res);
}
if (!mysqli_query($link, "SELECT id FROM test_mysqli_class_mysqli_result_interface_table_1 ORDER BY id")) {
    printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!is_object($res = new mysqli_result($link))) {
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:mysqli_class_mysqli_result_interface.php

示例8: pack

     $Packet .= pack('C', $Field->decimals);
     SendPacket($Packet);
 }
 $Packet = '';
 $Packet .= "þ";
 $Packet .= pack('v', mysqli_warning_count($mysqli));
 if ($MorePackets || mysqli_more_results($mysqli)) {
     $Packet .= pack('v', 0x8);
 } else {
     $Packet .= pack('v', 0x0);
 }
 // Server Status
 SendPacket($Packet);
 while ($Row = mysqli_fetch_array($result, MYSQL_NUM)) {
     $Packet = '';
     $Lengths = mysqli_fetch_lengths($result);
     for ($i = 0; $i < mysqli_num_fields($result); $i++) {
         if (!isset($Row[$i])) {
             $Packet .= "û";
         } else {
             $Packet .= PackLength($Lengths[$i]) . $Row[$i];
         }
     }
     SendPacket($Packet);
 }
 $Packet = '';
 $Packet .= "þ";
 $Packet .= pack('v', mysqli_warning_count($mysqli));
 if ($MorePackets || mysqli_more_results($mysqli)) {
     $Packet .= pack('v', 0x8);
 } else {
开发者ID:BengiTiger119,项目名称:MySQL-Front,代码行数:31,代码来源:libMySQL.php

示例9: mysql_compat_fetch_lengths

function mysql_compat_fetch_lengths($result)
{
    return mysqli_fetch_lengths($result);
}
开发者ID:bAndie91,项目名称:mysql-compat-php,代码行数:4,代码来源:mysql_compat.php

示例10: sql5

function sql5($sql, $p = '', $nt = '')
{
    static $i, $Acache;
    $i++;
    if (is_array($sql)) {
        extract($sql);
    }
    #
    if (isset($Acache[md5($sql)])) {
        return $Acache[md5($sql)];
    }
    #if(j9&&strpos(u,'607b'))av('DB:'.DB);
    if ($p == 1 or $nt == 1) {
        $close = 1;
        unset($p, $nt);
    }
    if (strpos($sql, '.s3db')) {
        Preg_match('~[^ ]+\\.s3db\\.~i', $sql, $m);
        $p = trim($m[0], '.');
        $sql = str_replace($m[0], '', $sql);
    }
    if (strpos($p, '.s3db')) {
        return sqlite($sql, $p, $close);
    }
    #no=1,bd=ben,pile=id,np=0
    if ($p) {
        if ($y = param($p)) {
            extract($y);
        }
    }
    gt('0:sql5' . $i . __LINE__);
    $_ENV['sql'][] = $sql;
    $x = sql($sql, $bd, $p);
    gt('1:sql5' . $i . __LINE__);
    if (is_numeric($x)) {
        return $x;
    }
    if (!$x) {
        return;
    }
    #retour de Num_rows quand update
    $nr = mysqli_num_rows($_ENV['sqlquery']);
    if ($nr < 1) {
        return;
    }
    #Si resultat vide#Seulement sur un select
    #$if($len>30000000)
    $mem = memory_get_usage();
    if ($mem > 30000000) {
        $len = array_sum(mysqli_fetch_lengths($x));
        DBM('debugmem', "sql:{$sql}, len:{$len}, mem:{$mem}");
    }
    gt('0:sql5while' . $i . __LINE__);
    while ($t = mysqli_fetch_assoc($x)) {
        #Memleak Here ///
        #@mysql_volume_kilobytes:sizeof($R)>90.000.000 ????
        #if($mem>40000000)DBM('debugmem',$sql.pre($t).$mem);
        if ($nc) {
            $R[] = $t;
            continue;
        }
        #2dim Array for 1D Array, no collapse, original form switch
        if ($nr == 1 && $np) {
            $R = $t;
            break;
        }
        #Single Array for Result
        if ($pile) {
            $id = $t[$pile];
            unset($t[$pile]);
            $R[$id] = $t;
            continue;
        }
        //Replaces the key with some value(id)
        if ($nr == 1 && count($t) == 1 && !$no) {
            $R = end($t);
            break;
        }
        #1single results return a string
        if ($nr == 1 && !$no) {
            $R = $t;
            break;
        }
        #1 column returns 1 dimension Array
        if (count($t) == 1 and !$no) {
            $R[] = end($t);
            continue;
        }
        #2dim-1single value//Un seul élément => Dépilé !
        $R[] = $t;
        //todo:MemError allocation here
    }
    #if(j10){print_r(compact('R','t'));die;}
    if ($_ENV['sqlcache'] || $cache) {
        $Acache[md5($sql)] = $R;
    }
    #if(strpos(U,'webcam.php')){print_r(compact('R','sql'));die;}
    gt('1:sql5while' . $i . __LINE__);
    #14ms dans le while
    mysqli_free_result($x);
//.........这里部分代码省略.........
开发者ID:Ben749,项目名称:racetrack,代码行数:101,代码来源:fun.php

示例11: yog_mysql_fetch_lengths

    switch (DB_EXTENSION) {
        case "mysql":
            $ret = mysql_fetch_array($result);
            break;
        case "mysqli":
            $ret = mysqli_fetch_array($result);
            break;
    }
    return $ret;
}
function yog_mysql_fetch_lengths($result)
{
    //Get the length of each output in a result
    $ret = array();
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:14,代码来源:andrews-tunnel.php


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