通过PHP的Windows索引搜索不会返回图像

时间:2019-08-02 17:16:32

标签: php windows winapi indexing adodb

我正在使用Windows索引搜索和PHP来搜索数千个文件。

我通过使用PHP COM类使其工作。

但是问题是搜索结果仅返回找到的txt,docx,pdf和文档类型的文件。无论我尝试搜索什么属性,它都不会返回图像或视频。

当我搜索001作为字符串时:

实际结果:y:/sample001.txt,y:/book001.pdf

也希望看到:y:/picture001.jpg

但是结果不显示jpg或任何其他类型的媒体文件。

为什么不搜索图像(或视频)?

在此先感谢您的帮助。

<?php # searchfunction.php

function comsearch($string){
    $path = "file:y:/";
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
    $recordset = new COM("ADODB.Recordset");

    //setting the limit for the query
    $recordset->MaxRecords = 1000;

    $conn->Open("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");

    //creating the query against windows search indexer database.
    //we specify the path and the string we are looking for

    $recordset->Open("SELECT System.FileName, System.ItemPathDisplay, System.FileExtension FROM SYSTEMINDEX WHERE SCOPE='".$path."' AND CONTAINS('".$string."') AND System.FileExtension='.jpg'", $conn);

    if(!$recordset->EOF){
        $recordset->MoveFirst();
    }
    $files = array();
    while(!$recordset->EOF) {

        $filename = $recordset->Fields->Item("System.FileName")->value;

        $files[]=  $filename;
        $recordset->MoveNext();
    }

    return $files;
}
?>

即使我的目录中有成千上万个.jpg,上面的代码也不会在条件System.FileExtension ='。jpg'下返回任何内容。

但是当我尝试不使用此条件时,结果将成功返回同一目录中的txt,pdf和其他文档类型的文件。

我做错了什么?

0 个答案:

没有答案