- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的查询是对三个表进行几个左连接。返回的行数为 30k。行非常大。
查询执行得很好(因为在 mysql_query($sql) 中不会导致错误)。
如果我使用 while($row = mysql_fetch_array($result)){} 遍历此查询,则没有问题。但是,在 while 循环之前我这样做:
$types = array();
while($field = mysql_fetch_field($result)){
switch($field->type) {
case "int":
$types[$field->name] = 'int';
break;
case "real":
$types[$field->name] = 'float';
break;
default:
$types[$field->name] = 'string';
break;
}
}
并且 php 在 mysql_fetch_field
行抛出一个 fatal error :
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes)
这是为什么,为什么 mysql_fetch_array
while 循环也不会导致内存问题?以及如何使用 mysql_fetch_field
获取字段名称类型。
最佳答案
尝试使用带偏移量的mysql_fetch_field
$types = array();
$index=0;
$num_fields=mysql_num_fields($resource);
while($index<$num_fields) {
$field=mysql_fetch_field($resource, $index);
switch($field->type) {
case "int":
$types[$field->name] = 'int';
break;
case "real":
$types[$field->name] = 'float';
break;
default:
$types[$field->name] = 'string';
break;
}
$index++;
}
关于php - 为什么 mysql_fetch_field 会在此查询中耗尽内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31233080/
我需要根据选择的结果类型在其他数据库中创建表。查询结果可以映射到表中的实际列,也可以不映射到表中的实际列。 从 char_length_test 中选择 1, c。 如何使用 mysql C api
我正在运行一个 while 循环来打印表中的某些数据。因为表的数据存储在一个非常大的表中,所以我听说创建一个单独的表来存储该表的相关数据的行数是一个好主意。我正在尝试实现这个,但运气不太好,为什么下面
我的查询是对三个表进行几个左连接。返回的行数为 30k。行非常大。 查询执行得很好(因为在 mysql_query($sql) 中不会导致错误)。 如果我使用 while($row = mysql_f
我有这样的代码 我有一个存储过程,它将获取所有信息。但我希望在我的 php View 部分中仅显示选定的字段。我怎样才能做到这一点。例如:下面的代码在 db 中有三个字段。 S.No - 书名 - 作
我是一名优秀的程序员,十分优秀!