mysqli 有更多问题.结果中的数值数据 [英] Having more issues with mysqli. Numerical data in results

查看:113
本文介绍了mysqli 有更多问题.结果中的数值数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 print_r 时,我在数组块之间得到一个数字 1.我不知道它来自哪里.

When I do a print_r, I get a number 1 between the array blocks. I have no idea where it is coming from.

这导致我的日志出错.我可以通过使用 is_array 进行测试来解决这个问题,但我想知道这是从哪里来的.

This is causing errors in my log. I can fix this by testing with is_array but I want to know where this is coming from.

我正在做两个查询,但我在那里有第三个数组.这是怎么回事??????

I'm making two queries but yet I have a third array in there. What is going on?????

mysqli_result Object
(
    [current_field] => 0
    [field_count] => 2
    [lengths] => 
    [num_rows] => 110
    [type] => 0
)
mysqli_result Object
(
    [current_field] => 0
    [field_count] => 1
    [lengths] => 
    [num_rows] => 12
    [type] => 0
)
1                    <-------------------------------------HERE
mysqli_result Object
(
    [current_field] => 0
    [field_count] => 1
    [lengths] => 
    [num_rows] => 1
    [type] => 0
)

<小时>

$this->conn->query("CALL phoneIsRegistered($phone,@phone)");

$res = $this->conn->query("SELECT @phone");

<小时>

    $result = mysqli_query($this->conn, $query) or die('Error: '.mysqli_error($this->conn));

    if($result)
    {
        while($row = $result->fetch_object())
        {
            if($row)
            {
                print_r($row);
            }
        }
        $this->disconnect();
    }

这就是我开始尝试查找之前循环的样子.

This is what the loop looked like before I began trying to find this.

    $this->connect();
    $result = mysqli_query($this->_conn, $query) or die('Error: '.mysqli_error($this->conn));

    if($result){
        $i=0;
        $res = array();
        while($row = $result->fetch_object()){
            if($row){
                $res[$i++] = $row;
            }
        }
        $this->disconnect();
        return $res;
    }else{
        return false;
    }

推荐答案

除了使用 print_rvardump 之外,你应该考虑使用 FirePHPPHP快速分析器可帮助您调试和显示变量的值.

Beside using print_r or vardump, you should consider using FirePHP or PHP Quick Profiler to help you debugging and displaying variable's value.

使用 FirePHP,您可以将值显示到 Firebug 的控制台中.使用,PHP Quick Profiler,会在底部添加一个控制台可用于显示您需要的任何值的页面.

With FirePHP, you can display the value into Firebug's console. Using, PHP Quick Profiler, there will be a console added at the bottom of the page that can be used to display any value that you need.

这篇关于mysqli 有更多问题.结果中的数值数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆