简体   繁体   English

全文搜索适用于 mysql 但不适用于 php

[英]Full text search works in mysql but not php

I have the following in php:我在 php 中有以下内容:

public function myfunction($v){
//ini_set("memory_limit","32M");
$v=mysqli_real_escape_string($this->connection,$v);
 $stmt=mysqli_prepare($this->connection,"SELECT * from TABLE WHERE MATCH(column) AGAINST($v)");

    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    $rows=array();

      mysqli_stmt_bind_result($stmt,$row->column1,$row->column2);

    while (mysqli_stmt_fetch($stmt)) {

      $rows[]=$row;
      $row = new stdClass();

      mysqli_stmt_bind_result($stmt,$row->column1,$row->column2);

    }

    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);
print_r('this is a test');
print_r($rows);
}

This is searching a longtext column that has a fulltext index.....这是搜索具有全文索引的长文本列.....

Running this code (w/ the ini_set commented out) I get a memory size exhausted error.运行此代码(带有注释掉的 ini_set)我收到 memory 大小耗尽错误。 When I uncomment the ini_set part and increase the memory I get no output and no errors (not even 'this is a test' gets printed).当我取消注释 ini_set 部分并增加 memory 我没有得到 output 并且没有错误(甚至没有打印“这是一个测试”)。

Why am I not getting any output (or at least an error statement) when I increase the memory?当我增加 memory 时,为什么我没有收到任何 output(或至少一个错误声明)? I have not adjusted my error reporting in php.我没有调整我在 php 中的错误报告。

(Running the same statement directly in mysql (without increasing the memory limit) takes.0007 seconds) (直接在 mysql 中运行相同的语句(不增加 memory 限制)需要.0007 秒)

Because you save all the records that mysql gave in your $rows array.因为您将 mysql 提供的所有记录保存在$rows数组中。

If the recordset is huge then you get that error.如果记录集很大,那么您会收到该错误。
Also your syntax with a double call of mysqli_stmt_bind_result($stmt,$row->column1,$row->column2);还有你的语法,两次调用mysqli_stmt_bind_result($stmt,$row->column1,$row->column2); isn't that good looking是不是很好看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM