1

さて、私はこのスクリプトを作成しました。これにより、見つけることができますが、正しく機能しません。私はプログラミングの問題を抱えています-これを正しく動作するようにプログラミングします。正しく機能していないようです。

この関数は、銀行取引明細書からの支払いでいっぱいのデータベース内に表示される各行で宣言されます。単純に$a, $b, $c, $dタイプ(BAC、TRSなど)、説明(35 QUEENS ROAD RENT)、金額(£500.00)です。

特定のユーザーに接続されている住所/プロパティ、名前、家賃に応じて、特定のユーザーへの支払いを調整する関数を作成しようとしています。

これは私がこれまでに持っているものです:

   function reconcile($a,$b,$c,$d) {

    //when the user clicks on the text fild, jquery loads the various names needed from the database
    //when the user clicks on the selected field, the value is saved via ajax and saved on the server the reconciled field

    //break down the inputs into an array
    //create SQL query that matches all of these key words

    //create keywords database
    $keywords = $a . " " . $b . " " . $c . " " . $d;

    //remove commas, dashes and other keywords from database that might be a nuisance
    //change names like ave to avenue
    $keywords = str_replace("'", "", $keywords);
    $keywords = str_replace("-", "", $keywords);
    $keywords = str_replace(",", "", $keywords);
    $keywords = str_replace("A/C", "", $keywords);
    $keywords = str_replace("TO", "", $keywords);
    $keywords = str_replace("CALL", "", $keywords);
    $keywords = str_replace("REF.NO.", "", $keywords);
    $keywords = str_replace("TO", "", $keywords);
    $keywords = preg_replace("/\s+/", " ", $keywords);
    $keywords = str_replace("  ", "", $keywords);
    $keywords = addslashes($keywords);
    $keywords = mysql_real_escape_string($keywords);

    $keywords = explode(" ", $keywords);
    //$keywords = remove_from_array($keywords, 2);




    //match keywords to keywords database

    $matches = array();

    //search 5 databases...

    $i=0;

    foreach($keywords as $keyword) {

        //add more fields
        //check distinct

        //do not allow any keywords that are smaller than 3
        if(strlen($keyword) < 3) {
            continue;
        }

        $get = mysql_query("SELECT DISTINCT `users`.`id` FROM `users` LEFT JOIN `addresses` ON `users`.`id` = `addresses`.`user` WHERE (`users`.`fname` LIKE '%$keyword%' OR `users`.`lname` LIKE '%$keyword%') OR (((`addresses`.`flat` LIKE '%$keyword%' OR `addresses`.`address` LIKE '%$keyword%') OR (`addresses`.`district` LIKE '%$keyword%' OR `addresses`.`town` LIKE '%$keyword%')) OR (`addresses`.`county` LIKE '%$keyword%' OR `addresses`.`postcode` LIKE '%$keyword%'));") or die("Error: " . mysql_error());
        if(mysql_num_rows($get) > 0) {
            while($fetch = mysql_fetch_array($get)) {
                list($uid) = $fetch; //$uid = user id
                //insert $uid into array
                //1 => 3 times
                //find number if exists and then add to that number

                //search array and echo attempts (if any)

                if(in_array($uid, $matches)) {
                    //add one to the key
                    $matches[$uid]++;
                } else {
                    array_push($matches, $uid);
                }

                $i++;

                //save search to database

            }

            //create array for user
            //add up relevance for that user

        }

    }

    $relevance = 0;

    if($i > $relevance) {
        //change javascript function and link with ajax.php
        echo "<span onClick=\"javascript:void(0)\" style=\"cursor:pointer;\" class=\"label label-success\">Accept</span>\n\r";
        //change to jquery function that allows a drop down of names from the database
        echo "<input type=\"text\" style=\"width:140px\" value=\"" . $matches[0] . "\" />\n\r";
    }

}

私はこれを行う配列を追加することを考えていました:

[0] (user id) => 3 (how many times that user id is found through one row of a bank statement)

したがって、たとえば、ユーザー3が37 Kings Avenueの物件を所有していて、キーワードが「Avenue」の場合、[3] => 1追加のユーザーの結果は次のようになります。

「同意する」ボタンは、ユーザーがシステムの調整を受け入れ、テキスト入力に他の関連する名前/すべての名前とアドレスのドロップダウンが表示されることを意味します。

4

2 に答える 2

1

sphinx公式サイト)もあります。サーバーへのrootアクセス権があるかどうかを確認して、必要なサーバープロセスを実行できるようにしてください。セットアップは簡単で、関連する結果を出すのに非常に優れています。キーワードまたはキーワードのセットに一致するものをすべて取得できるため、基本的にすべてのキーワードをそれにスローでき、すべての結果が最高の状態で得られます。上に一致します。

また、非常に高速で、デルタインデックス(インデックスを再構築するためにすべてのデータを調べる必要なしに新しいデータを追加する)が可能であるため、オフピーク時に完全な再インデックスを実行できます。

本当に簡単にしたい場合は、MySQLプラグインSphinxSEを使用することをお勧めします。これにより、通常のmysqlテーブルのようにクエリを実行し、元のテーブルに結合して簡単にアクセスできます。

gentooを使用している場合は、このebuildを使用して、プラグインにmysqlを追加するだけです。

于 2012-07-02T20:07:31.270 に答える
1

データベース/テーブル/ビューからいくつかのデータを検索したい場合は、SQLyog の データ検索機能を使用できます。サーバー内のデータを検索します。それはGoogle検索のように機能します!「データ検索」機能を使用すると、実際に SQL を記述しなくても特定のデータを見つけることができます。データベースまたはテーブルのデータ型/サブセットによってデータをフィルタリングできます。

30 日間の試用版をダウンロードして、この MySQL GUI を評価してみてください。

ここに画像の説明を入力

于 2012-07-02T17:43:10.100 に答える