gpt4 book ai didi

php - 如何使用 PHP 指定要搜索的多个列?

转载 作者:行者123 更新时间:2023-11-29 11:26:14 26 4
gpt4 key购买 nike

我最近建立了一个工作网站,因为我们的技术人员需要一种简单的方法来找出我们提供服务的属性的 key 。我已经让该网站支持实时搜索 (Ajaxlivesearch.com),并且它链接到我的 MySQL 数据库。除了当前仅搜索一列(Address 列)之外,一切都运行良好。我希望能够同时搜索两列:AddressProperty_Name

这是当前的代码,或者至少是处理数据库搜索的部分。

<?php

namespace AjaxLiveSearch\core;

if (count(get_included_files()) === 1) {
exit('Direct access not permitted.');
}

/**
* Class Config
*/
class Config
{
/**
* @var array
*/
private static $configs = array(
// ***** Database ***** //
'dataSources' => array(
'ls_query' => array(
'host' => '',
'database' => '',
'username' => '',
'pass' => '',
'table' => '',
// specify the name of search columns
'searchColumns' => array('Address'),
// specify order by column. This is optional
'orderBy' => '',
// specify order direction e.g. ASC or DESC. This is optional
'orderDirection' => '',
// filter the result by entering table column names
// to get all the columns, remove filterResult or make it an empty array
'filterResult' => array(),
// specify search query comparison operator. possible values for comparison operators are: 'LIKE' and '='. this is required.
'comparisonOperator' => 'LIKE',
// searchPattern is used to specify how the query is searched. possible values are: 'q', '*q', 'q*', '*q*'. this is required.
'searchPattern' => 'q*',
// specify search query case sensitivity
'caseSensitive' => false,
// to limit the maximum number of result uncomment this:
'maxResult' => 10,
// to display column header, change 'active' value to true
'displayHeader' => array(
'active' => true,
'mapper' => array(
'Property_Name' => 'Property Name',
'Address' => 'Address',
'Key' => 'Key',
'Property_Manager' => 'Property Manager',
'Door_Code' => 'Door Code'
)
),
// add custom class to <td> and <th>
// To hide a column use class 'ls_hide'
'columnClass' => array(
'Count' => 'ls_hide',
'Reserve' => 'ls_hide'
),
'type' => 'mysql',
),

出于显而易见的原因,我已经删除了连接信息。

我尝试了 'searchColumns' => array('Address' AND 'Property_Name'),认为这会搜索两列,但根本不起作用。

最佳答案

我不熟悉 Ajaxlivesearch,但看起来 searchColumns 需要一个数组,所以:

 'searchColumns' => array('Address', 'Property_Name'),

可能会起作用。

(array('Address' AND 'Property_Name') 是一个语法错误。)

关于php - 如何使用 PHP 指定要搜索的多个列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38155303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com