偏移量0对MySQL结果索引64无效(或查询数据未缓冲)

编程入门 行业动态 更新时间:2024-10-19 22:27:49
本文介绍了偏移量0对MySQL结果索引64无效(或查询数据未缓冲)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用php和mysql,突然间我得到了

I am working with php and mysql and suddenly I get

mysql_data_seek()[function.mysql-data-seek]:偏移0对MySQL结果索引64无效(或查询数据未缓冲)

mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 64 (or the query data is unbuffered)

这是什么意思.

我不知道从哪里开始调试这个.

I have no idea where to start to debug this one.

该类将mysql资源传递到其构造函数中


This class is passed a mysql resource into it's constructor

class dbResult { private $result; private $num_rows; function __construct($result) { $this->result = $result; } function result($type = 'object') { @mysql_data_seek($this->result, 0); if ($type == 'array') return mysql_fetch_assoc($this->result); if ($type == 'object') { if ($this->num_rows() == 1) { $data = new stdClass(); foreach (mysql_fetch_assoc($this->result) as $k => $v) $data->$k = $v; return $data; } if ($this->num_rows() > 1) { $data = array(); while ($result = mysql_fetch_assoc($this->result)) { $row = new stdClass(); foreach ($result as $k => $v) $row->$k = $v; $data[] = $row; } return $data; } return false; } } function num_rows() { return mysql_num_rows($this->result); } function num_fields() { return mysql_num_fields($this->result); } }

推荐答案

如果结果集为空,则mysql_data_seek()将失败,并显示E_WARNING.我认为这是在您的情况下发生的,因为您在调用mysql_data_seek()之前没有检查结果集是否为空.

if the result set is empty mysql_data_seek() will fail with a E_WARNING. That is I think happening in you case because you are not checking whether the result set is empty or not before calling the mysql_data_seek().

如果行数大于等于1,则始终检查结果,然后可以安全地呼叫mysql_data_seek()

Always check the result for number of rows if they are >=1 then you are safe to call mysql_data_seek()

更多推荐

偏移量0对MySQL结果索引64无效(或查询数据未缓冲)

本文发布于:2023-11-12 04:07:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580475.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   偏移量   数据   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!