Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    33

    Unanswered: DB2 with PHP. How to do XML full text search

    Hello

    I'm developing dictionary. I know how to search certain keyword if the keyword (full word) is correctly inserted. However I don't how to retrieve the if a part of the word is inserted.

    As example, the code below will do if I insert 'Information Security', but not 'Security'.


    <?php
    if(!$_POST["keyword"])
    {
    echo "Please insert keyword<br />";
    }else{
    $conn = db2_connect("xxx", "xxx", "xxx");
    $query = 'SELECT * FROM XMLTABLE(
    \'db2-fn:xmlcolumn("TERM.TERM")/term\'
    COLUMNS
    "TERM" VARCHAR (5000) PATH \'term\' ,
    "DEFINITION" VARCHAR (5000) PATH \'definition\',
    ) AS T
    Where term = ?
    ';
    $stmt = db2_prepare($conn, $query);
    $term = $_POST["keyword"];

    if ($stmt) {
    db2_bind_param($stmt, 1, "term", DB2_PARAM_IN);
    db2_execute($stmt);
    while($row = db2_fetch_object($stmt)){
    printf("$row->TERM $row->DEFINITIONn");
    }
    }
    db2_close($conn);
    }
    ?>
    I tried change '=' to 'like' but still no success.
    Where term = ?
    Any suggestion will be helpful.
    Thank You

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •