簡體   English   中英

全文搜索適用於 mysql 但不適用於 php

[英]Full text search works in mysql but not 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);
}

這是搜索具有全文索引的長文本列.....

運行此代碼(帶有注釋掉的 ini_set)我收到 memory 大小耗盡錯誤。 當我取消注釋 ini_set 部分並增加 memory 我沒有得到 output 並且沒有錯誤(甚至沒有打印“這是一個測試”)。

當我增加 memory 時,為什么我沒有收到任何 output(或至少一個錯誤聲明)? 我沒有調整我在 php 中的錯誤報告。

(直接在 mysql 中運行相同的語句(不增加 memory 限制)需要.0007 秒)

因為您將 mysql 提供的所有記錄保存在$rows數組中。

如果記錄集很大,那么您會收到該錯誤。
還有你的語法,兩次調用mysqli_stmt_bind_result($stmt,$row->column1,$row->column2); 是不是很好看

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM