私は最近、仕事用のWebサイトを構築しました。なぜなら、私たちの技術者は、サービスを提供するプロパティにどのキーが行くのかを簡単に見つける方法を必要としているからです。ライブ検索(Ajaxlivesearch.com)で動作するサイトを取得し、MySQLデータベースにリンクしています。現在1つの列、つまりAddress
列のみを検索することを除いて、すべてがうまく機能します。私は2つの列を検索できるようにしたいと、思いAddress
とProperty_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')
構文エラーです。)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加