Can't get simple search to work (split of previous question)

Can't get simple search to work (split of previous question)

obrienjobrienj Posts: 93Questions: 38Answers: 0

Allan,

The simple search question, I didn't know there needed to be some special PHP code but to answer your request, this development is only running on my development laptop using WAMP64 installed on it so a link is virtually impossible.

So I have included both the Datatbales definition and my PHP code. As noted below I have not included some purpose built code in preCreate, preEdit, and preRemove which makes the PHP code quite long. If it is necessary I can include it in a subsequent post.

Datatables (client-side):

table = $('#cc-list').DataTable({
     processing: true,
     serverSide: true,
     paging: true,
     searching: true,
     select: true,
     responsive: true,
     ordering: true,
     orderFixed: [0, 'asc'],
 
     ajax: {
         url: "OTCalMaint.php",
         type: "POST"
     },
     columns: [
         {
             "data": "start",
             "searchable": true
         },
         {
             "data": "end",
             "searchable": true
         },
         {
             "data": "title",
             "searchable": true
         },
         {
             data: null,
             searchable: false,
             className: "center",
             defaultContent: '<a href="" class="editor_edit">Edit</a> / <a href="" class="editor_copy">Copy</a> / <a href="" class="editor_remove">Delete</a>'
         }
     ],
     columnDefs: [
         {
             "targets": 0,
             "data": null,
             "title": "Date",
             "width": "10%",
             "render": function (data, type, row, meta) {
                 var wrks = moment(row.start, 'dddd, MMMM D, YYYY h:mm A');
                 var wrke = moment(row.end, 'dddd, MMMM D, YYYY h:mm A');
                 var wrkd = moment(wrks).format('ddd MMM D');
                 return "" + wrkd;
             }
         },
         {
             "targets": 1,
             "data": null,
             "title": "Time",
             "width": "14%",
             "render": function (data, type, row, meta) {
                 var wrks = moment(row.start, 'dddd, MMMM D, YYYY h:mm A');
                 var wrke = moment(row.end, 'dddd, MMMM D, YYYY h:mm A');
                 if (row.allDay == '1') {
                     var wrkd = moment(wrks).format('h:mm A') + " -  All Day";
                 } else {
                     var wrkd = moment(wrks).format('h:mm A') + " - " + moment(wrke).format('h:mm A');
                 }
                 return "" + wrkd;
             }
         },
         {
             "targets": 2,
             "data": null,
             "title": "Event",
             "width": "60%",
             "render": function (data, type, row, meta) {
                 var wloc = "";
                 var wrkt = "";
 
                 if (row.location == null) {
                     wrkt = row.title + " - " + row.city + ", " + row.state + " " + row.zipcode;
                 } else {
                     wrkt = row.title + " - " + row.location;
                 }
 
                 return "" + wrkt.trim();
             }
         }
     ],
     buttons: [
         { extend: "create", editor: editor },
         { extend: "edit", editor: editor },
         { extend: "remove", editor: editor }
     ]
 });

Server-side PHP

#region Editor definition
//---------------------------------------------------------------------
// Build Editor instance and process the data coming from _POST
//---------------------------------------------------------------------
Editor::inst( $db, 'calendar.events', 'RID' )
 
    ->fields(
        Field::inst( 'RID' )
            ->set(false),                           // ID is automatically set by the database on create
 
        Field::inst( 'id' ),
 
        Field::inst( 'title' ),
 
        Field::inst( 'allDay' ),
 
        Field::inst( 'action' ),
 
        Field::inst( 'start' )
            ->validator( 'Validate::dateFormat', array(
                "format"  => 'l, F j, Y g:i A',
                "message" => "Please enter a date in the correct format"
            ) )
            ->getFormatter( 'Format::datetime', array(
                'from' => 'Y-m-d H:i:s',
                'to' =>   'l, F j, Y g:i A'
            ) )
            ->setFormatter( 'Format::datetime', array(
                'from' => 'l, F j, Y g:i A',
                'to' =>   'Y-m-d H:i:s'
            ) ),
 
        Field::inst( 'end' )
            ->validator( 'Validate::dateFormat', array(
                "format"  => 'l, F j, Y g:i A',
                "message" => "Please enter a date in the correct format"
            ) )
            ->getFormatter( 'Format::datetime', array(
                'from' => 'Y-m-d H:i:s',
                'to' =>   'l, F j, Y g:i A'
            ) )
            ->setFormatter( 'Format::datetime', array(
                'from' => 'l, F j, Y g:i A',
                'to' =>   'Y-m-d H:i:s'
            ) ),
 
        Field::inst( 'whenHold' )->setFormatter( 'Format::nullEmpty' ),
 
        Field::inst( 'rptHold' )->setFormatter( 'Format::nullEmpty' ),
 
        Field::inst( 'rfc5545' ),
 
        Field::inst( 'rfcDates' ),
 
        Field::inst( 'rfcid' ),
 
        Field::inst( 'location' ),
 
        Field::inst( 'description' ),
 
        Field::inst( 'placeID' ),
 
        Field::inst( 'institution' ),
 
        Field::inst( 'address' ),
 
        Field::inst( 'city' ),
 
        Field::inst( 'state' ),
 
        Field::inst( 'country' ),
 
        Field::inst( 'zipcode' ),
 
        Field::inst( 'neighborhood' ),
 
        Field::inst( 'phone' ),
 
    Field::inst( 'webURL' ),
 
        Field::inst( 'mapURL' ),
 
    Field::inst( 'locPicURL' ),
 
        Field::inst( 'latitude' ),
 
        Field::inst( 'longitude' )
 
    )
    #endregion
 
// I have left out preCreate, preEdit, preRemove,  and several support functions
 
#region Processing
    ->process( $_POST )
 
     ->json();
#endregion

If I type a word into the client-side "Search" box that I know is in a "title" nothing happens.

Regards,
Jim

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    What does the server respond with? This tech note shows how you can see what the server is responding with.

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    I looked the the traffic via the Network component of the Web Console in Firefox and found that there is a request and response for every character I type in the searchbox, "s i n g l e" and all of the responses include all of the table rows (10 in my test database).

    Only one of the rows in the database includes the word "single" anywhere and that is in the column "title" and it is declared searchable but it is not explicitedly displayed in the Datatables list but is used as part of an aggregate column in the list as can be seen in the "columnDefs: target:2 Rendering" above..

    To repeat for clarity, I have made no changes to my server-side or client-side to support searching other than to make certain that the required columns are declared searchable and those remain the same as shown in the original post above.

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    and found that there is a request and response for every character I type in the searchbox, "s i n g l e" and all of the responses include all of the table rows (10 in my test database).

    That suggests that the WHERE condition for the server-side processing search isn't having any effect.

    First question is - do you need server-side processing? If you aren't going to be working with tens of thousands or more rows, just use client-side processing.

    If you do need server-side processing, enable the debug feature of the libraries (add ->debug( true ) immediately before the ->process(...) call), and then show me the JSON that is being returned from the server when you search for something.

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Where do I find the JSON of which you speak?

    In the mean time I'll keep looking for it?

    Regards,
    Jim

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Follow this tech note to get the JSON response:
    https://datatables.net/manual/tech-notes/1

    Kevin

  • obrienjobrienj Posts: 93Questions: 38Answers: 0
    edited August 2017

    Allan,

    I looked in the Network tab again and this is the last request (I believe) and the response is follows.

    Is there something else you are looking for?

    draw    "14"
    columns[0][data]    "start"
    columns[0][name]    ""
    columns[0][searchable]  "true"
    columns[0][orderable]   "true"
    columns[0][search][value]   ""
    columns[0][search][regex]   "false"
    columns[1][data]    "end"
    columns[1][name]    ""
    columns[1][searchable]  "true"
    columns[1][orderable]   "true"
    columns[1][search][value]   ""
    columns[1][search][regex]   "false"
    columns[2][data]    "title"                                  <===== this is the column where "single" is
    columns[2][name]    ""
    columns[2][searchable]  "true"
    columns[2][orderable]   "true"
    columns[2][search][value]   ""
    columns[2][search][regex]   "false"
    columns[3][data]    "description"
    columns[3][name]    ""
    columns[3][searchable]  "true"
    columns[3][orderable]   "true"
    columns[3][search][value]   ""
    columns[3][search][regex]   "false"
    columns[4][data]    ""
    columns[4][name]    ""
    columns[4][searchable]  "false"
    columns[4][orderable]   "true"
    columns[4][search][value]   ""
    columns[4][search][regex]   "false"
    order[0][column]    "0"
    order[0][dir]   "asc"
    order[1][column]    "0"
    order[1][dir]   "asc"
    start   "0"
    length  "10"
    search[value]   "single"                          <========== this is what I'm searching for
    search[regex]   "false"
    

    And this is the companion response:

        
    JSON    
    data    [10]
    0   Object
    DT_RowId    "row_1"
    RID "1"
    id  "5996cf613ae167.82098036"
    title   "recurring"
    allDay  ""
    action  "0"
    start   "Friday, August 18, 2017 1:30 PM"
    end "Friday, August 18, 2017 2:30 PM"
    whenHold    null
    locHold null
    rfc5545 "RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=10"
    rfcDates    "2017-08-18 13:30:00~2017-08-1…13:30:00~2017-09-08 14:30:00"
    rfcid   "5996cf613add39.95855268"
    location    "Zack's BBQ, 721 E Bridge St, Hotchkiss, CO 81419, USA"
    description "<p>recurring</p>\n"
    placeID "ChIJD6BEhSG9QIcRpBI7s89KLvU"
    institution "Zack's BBQ"
    address "721 E Bridge St"
    city    "Hotchkiss"
    state   "CO"
    country "US"
    zipcode "81419"
    neighborhood    ""
    phone   "(970) 872-3199"
    webURL  "http://www.zacksbbq.net/"
    mapURL  "https://maps.google.com/maps?…tchkiss,%20CO%2081419,%20USA"
    locPicURL   "https://maps.google.com/?cid=17667140644146713252"
    latitude    "38.7987237"
    longitude   "-107.71074540000001"
    
    ================ data removed so post would fit ====================
    
    3   Object
    DT_RowId    "row_17"
    RID "17"
    id  "59970b90b3c9b6.63116524"
    title   "recurring single"             <============== this is where "single" is
    allDay  ""
    action  "0"
    start   "Friday, August 25, 2017 2:30 PM"
    end "Friday, August 25, 2017 3:30 PM"
    whenHold    null
    locHold null
    rfc5545 "RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=10"
    rfcDates    "2017-08-25 14:30:00~2017-08-2…14:30:00~2017-09-15 15:30:00"
    rfcid   "5996cf613add39.95855268"
    location    "Zack's BBQ, 721 E Bridge St, Hotchkiss, CO 81419, USA"
    description "<p><!--++++++++++++++++++++++…nbsp;</p>\n\n<p>&nbsp;</p>\n"
    placeID "ChIJD6BEhSG9QIcRpBI7s89KLvU"
    institution "Zack's BBQ"
    address "721 E Bridge St"
    city    "Hotchkiss"
    state   "CO"
    country "US"
    zipcode "81419"
    neighborhood    ""
    phone   "(970) 872-3199"
    webURL  "http://www.zacksbbq.net/"
    mapURL  "https://maps.google.com/maps?…tchkiss,%20CO%2081419,%20USA"
    locPicURL   "https://maps.google.com/?cid=17667140644146713252"
    latitude    "38.7987237"
    longitude   "-107.71074540000001"
    
    ================ data removed so post would fit ====================
    
    options []
    files   []
    draw    14
    recordsTotal    "10"
    recordsFiltered "10"
    debugSql    [3]
    0   Object
    1   Object
    2   Object
    

    And I have verified the row I noted above is the only place "single:" occurs.

    Regards,
    Jim

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Also Allan may be looking for the output from this for your search:

    debug( true ">

    immediately before the ->process(...) call),

    Kevin

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    To answer a question that I missed, I do need to do searching on the server-side.

    Regards,
    Jim

  • obrienjobrienj Posts: 93Questions: 38Answers: 0
    edited August 2017

    Allan,

    I just saw the "debugSql" piece of the response when I search and it follows:

    9   Object                       <==== last item returned
    DT_RowId    "row_10"
    RID "10"
    id  "5996cf613f7eb2.25498431"
    title   "recurring"
    allDay  ""
    action  "0"
    start   "Friday, September 8, 2017 1:30 PM"
    end "Friday, September 8, 2017 2:30 PM"
    whenHold    null
    locHold null
    rfc5545 "RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=10"
    rfcDates    "2017-08-18 13:30:00~2017-08-1…13:30:00~2017-09-08 14:30:00"
    rfcid   "5996cf613add39.95855268"
    location    "Zack's BBQ, 721 E Bridge St, Hotchkiss, CO 81419, USA"
    description "<p>recurring</p>\n"
    placeID "ChIJD6BEhSG9QIcRpBI7s89KLvU"
    institution "Zack's BBQ"
    address "721 E Bridge St"
    city    "Hotchkiss"
    state   "CO"
    country "US"
    zipcode "81419"
    neighborhood    ""
    phone   "(970) 872-3199"
    webURL  "http://www.zacksbbq.net/"
    mapURL  "https://maps.google.com/maps?…tchkiss,%20CO%2081419,%20USA"
    locPicURL   "https://maps.google.com/?cid=17667140644146713252"
    latitude    "38.7987237"
    longitude   "-107.71074540000001"
    options []
    files   []
    draw    3
    recordsTotal    "10"
    recordsFiltered "10"
    debugSql    [3]                    <==== debugSql start
    0   Object
    query   "SELECT COUNT(RID) as 'cnt' F…description` like :where_5 )"
    bindings    [3]
    0   
    name    ":where_1"
    value   "%single%"
    type    null
    1   
    name    ":where_4"
    value   "%single%"
    type    null
    2   
    name    ":where_5"
    value   "%single%"
    type    null
    1   Object
    query   "SELECT COUNT(RID) as 'cnt' FROM `calendar`.`events` "
    bindings    []
    2   Object
    query   "SELECT `RID` as 'RID', `id` … asc, `start` asc LIMIT 10"
    bindings    [3]
    0   
    name    ":where_1"
    value   "%single%"
    type    null
    1   
    name    ":where_4"
    value   "%single%"
    type    null
    2   
    name    ":where_5"
    value   "%single%"
    type    null
    
  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    This is getting more curious:

    The following works just like it is supposed to:

     $('#cc-list').DataTable()
                     .column('title:name')
                     .search('chorus', false, true)
                     .draw();
    
    

    But this does not and neither does the search box:

     $('#cc-list').DataTable()
                      .search('chorus', false, true)
                      .draw();
    

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Hi Jim,

    Could you give me the raw JSON from the "Network" tab please? I'm finding it quite hard to follow the nesting of the data as it is pasted in above.

    Thanks,
    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    I will do my best. Current Firefox a bit different than the tech note but here are the request and the response.

    I am using less data this time and the search word is "c h" which should match only one row of 3.

    And this is using the "vanilla" search box.

    The request:

    draw    "30"
    columns[0][data]    "start"
    columns[0][name]    "start"
    columns[0][searchable]  "true"
    columns[0][orderable]   "true"
    columns[0][search][value]   ""
    columns[0][search][regex]   "false"
    columns[1][data]    "end"
    columns[1][name]    "end"
    columns[1][searchable]  "true"
    columns[1][orderable]   "true"
    columns[1][search][value]   ""
    columns[1][search][regex]   "false"
    columns[2][data]    "title"
    columns[2][name]    "title"
    columns[2][searchable]  "true"
    columns[2][orderable]   "true"
    columns[2][search][value]   ""
    columns[2][search][regex]   "false"
    columns[3][data]    "description"
    columns[3][name]    "description"
    columns[3][searchable]  "true"
    columns[3][orderable]   "true"
    columns[3][search][value]   ""
    columns[3][search][regex]   "false"
    columns[4][data]    "location"
    columns[4][name]    "location"
    columns[4][searchable]  "true"
    columns[4][orderable]   "true"
    columns[4][search][value]   ""
    columns[4][search][regex]   "false"
    columns[5][data]    "institution"
    columns[5][name]    "institution"
    columns[5][searchable]  "true"
    columns[5][orderable]   "true"
    columns[5][search][value]   ""
    columns[5][search][regex]   "false"
    columns[6][data]    "address"
    columns[6][name]    "address"
    columns[6][searchable]  "true"
    columns[6][orderable]   "true"
    columns[6][search][value]   ""
    columns[6][search][regex]   "false"
    columns[7][data]    "city"
    columns[7][name]    "city"
    columns[7][searchable]  "true"
    columns[7][orderable]   "true"
    columns[7][search][value]   ""
    columns[7][search][regex]   "false"
    columns[8][data]    "state"
    columns[8][name]    "state"
    columns[8][searchable]  "true"
    columns[8][orderable]   "true"
    columns[8][search][value]   ""
    columns[8][search][regex]   "false"
    columns[9][data]    "country"
    columns[9][name]    "country"
    columns[9][searchable]  "true"
    columns[9][orderable]   "true"
    columns[9][search][value]   ""
    columns[9][search][regex]   "false"
    columns[10][data]   "zipcode"
    columns[10][name]   "zipcode"
    columns[10][searchable] "true"
    columns[10][orderable]  "true"
    columns[10][search][value]  ""
    columns[10][search][regex]  "false"
    columns[11][data]   "neighborhood"
    columns[11][name]   "neighborhood"
    columns[11][searchable] "true"
    columns[11][orderable]  "true"
    columns[11][search][value]  ""
    columns[11][search][regex]  "false"
    columns[12][data]   "phone"
    columns[12][name]   "phone"
    columns[12][searchable] "true"
    columns[12][orderable]  "true"
    columns[12][search][value]  ""
    columns[12][search][regex]  "false"
    columns[13][data]   "latitude"
    columns[13][name]   "latitude"
    columns[13][searchable] "true"
    columns[13][orderable]  "true"
    columns[13][search][value]  ""
    columns[13][search][regex]  "false"
    columns[14][data]   "longitude"
    columns[14][name]   "longitude"
    columns[14][searchable] "true"
    columns[14][orderable]  "true"
    columns[14][search][value]  ""
    columns[14][search][regex]  "false"
    columns[15][data]   "category"
    columns[15][name]   "category"
    columns[15][searchable] "true"
    columns[15][orderable]  "true"
    columns[15][search][value]  ""
    columns[15][search][regex]  "false"
    columns[16][data]   "allDay"
    columns[16][name]   "allday"
    columns[16][searchable] "true"
    columns[16][orderable]  "true"
    columns[16][search][value]  ""
    columns[16][search][regex]  "false"
    columns[17][data]   "whenHold"
    columns[17][name]   "whenHold"
    columns[17][searchable] "true"
    columns[17][orderable]  "true"
    columns[17][search][value]  ""
    columns[17][search][regex]  "false"
    columns[18][data]   ""
    columns[18][name]   ""
    columns[18][searchable] "false"
    columns[18][orderable]  "true"
    columns[18][search][value]  ""
    columns[18][search][regex]  "false"
    order[0][column]    "0"
    order[0][dir]   "asc"
    order[1][column]    "0"
    order[1][dir]   "asc"
    start   "0"
    length  "10"
    search[value]   "ch"
    search[regex]   "false"
    

    This is the response when the two characters "c h" were entered. Note that the response when just the "c" was entered was identical. All nodes are expanded but copy and paste removes the little triangles and messes up the format.

    data    [3]
    options []
    files   []
    draw    30
    recordsTotal    "3"
    recordsFiltered "3"
    debugSql    [3]
    0   Object
    query   "SELECT COUNT(RID) as 'cnt' F… `whenHold` like :where_19 )"
    bindings    [17]
    0   
    name    ":where_1"
    value   "%ch%"
    type    null
    1   
    name    ":where_4"
    value   "%ch%"
    type    null
    2   
    name    ":where_5"
    value   "%ch%"
    type    null
    3   
    name    ":where_6"
    value   "%ch%"
    type    null
    4   
    name    ":where_7"
    value   "%ch%"
    type    null
    5   
    name    ":where_8"
    value   "%ch%"
    type    null
    6   
    name    ":where_9"
    value   "%ch%"
    type    null
    7   
    name    ":where_10"
    value   "%ch%"
    type    null
    8   
    name    ":where_11"
    value   "%ch%"
    type    null
    9   
    name    ":where_12"
    value   "%ch%"
    type    null
    10  
    name    ":where_13"
    value   "%ch%"
    type    null
    11  
    name    ":where_14"
    value   "%ch%"
    type    null
    12  
    name    ":where_15"
    value   "%ch%"
    type    null
    13  
    name    ":where_16"
    value   "%ch%"
    type    null
    14  
    name    ":where_17"
    value   "%ch%"
    type    null
    15  
    name    ":where_18"
    value   "%ch%"
    type    null
    16  
    name    ":where_19"
    value   "%ch%"
    type    null
    1   Object
    query   "SELECT COUNT(RID) as 'cnt' FROM `calendar`.`events` "
    bindings    []
    2   Object
    query   "SELECT `RID` as 'RID', `id` … asc, `start` asc LIMIT 10"
    bindings    [17]
    0   
    name    ":where_1"
    value   "%ch%"
    type    null
    1   
    name    ":where_4"
    value   "%ch%"
    type    null
    2   
    name    ":where_5"
    value   "%ch%"
    type    null
    3   
    4   
    name    ":where_7"
    value   "%ch%"
    type    null
    5   
    name    ":where_8"
    value   "%ch%"
    type    null
    6   
    name    ":where_9"
    value   "%ch%"
    type    null
    7   
    name    ":where_10"
    value   "%ch%"
    type    null
    8   
    name    ":where_11"
    value   "%ch%"
    type    null
    9   
    name    ":where_12"
    value   "%ch%"
    type    null
    10  
    name    ":where_13"
    value   "%ch%"
    type    null
    11  
    name    ":where_14"
    value   "%ch%"
    type    null
    12  
    name    ":where_15"
    value   "%ch%"
    type    null
    13  
    name    ":where_16"
    value   "%ch%"
    type    null
    14  
    name    ":where_17"
    value   "%ch%"
    type    null
    15  
    name    ":where_18"
    value   "%ch%"
    type    null
    16  
    name    ":where_19"
    value   "%ch%"
    type    null
    
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    I find it easier to access the pure JSON using the Firebug add-on for Firefox.

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    I took tangerine's suggestion and used Firebug to get the raw JSON.

    But my post was too long.

    So, please let me know if there is a way to put this in a file and send that to you.

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    pastebin.com.

    Seriously - you can't get the raw JSON easily from Firefox now? Urgh... I'll update the tech note.

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    I have no idea what I'm doing with pastebin, but try this URL

    https://pastebin.com/BZv6kV9E

    Regards,
    Jim

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Seriously - you can't get the raw JSON easily from Firefox now?

    @Allan: I really couldn't say, it's just that I always use Firebug and never needed whatever inherent method Firefox has for digging deeper.

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    edited August 2017

    The search term there is ch, which appears in a number of locations in the three displayed rows - screenshot attached.

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0
    edited August 2017

    Allan,

    I am very sorry about that, I was in a hurry and traveling.

    I've run a second test using the search word "chorus" which only appears twice but in two columns in the same row, yet I get all three rows in the database.

    The pastebin is: https://pastebin.com/yjBpszeY

    I omitted the POST and Response for the letters "c h o r u" and only included POST and Response when I typed the "s", thus the search for "c h o r u s".

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Thank you.

    The SQL statement being executed contains:

    WHERE (`start` LIKE :where_1 OR(1=1)
           OR `title` LIKE :where_4
           OR `description` LIKE :where_5
           OR `location` LIKE :where_6
           OR `institution` LIKE :where_7
           OR `address` LIKE :where_8
           OR `city` LIKE :where_9
           OR `state` LIKE :where_10
           OR `country` LIKE :where_11
           OR `zipcode` LIKE :where_12
           OR `neighborhood` LIKE :where_13
           OR `phone` LIKE :where_14
           OR `latitude` LIKE :where_15
           OR `longitude` LIKE :where_16
           OR `category` LIKE :where_17
           OR `allDay` LIKE :where_18
           OR `whenHold` LIKE :where_19)
    

    That OR 1=1 is going to be causing everything to be matched.

    Your code above doesn't show a where condition being applied. Can you show me the full PHP without retractions?

    Thanks,
    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Here is the full PHP in Pastebin https://pastebin.com/QR7CeKXX

    Regards,
    Jim

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Again note that I do nothing relative to Search other than request the search box at the top of the list.

    The SQL statement you see must have been generated by Datatables because I didn't.

    And, a question of curiosity, is that conventional SQL, I don't recall ever seeing notation like in a SELECT:

    WHERE (`start` LIKE :where_1 OR(1=1)
           OR `title` LIKE :where_4
           OR `description` LIKE :where_5
    

    or are the phrases ":where_5" a substitution notation that is satisfied later in the process?

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    are the phrases ":where_5" a substitution notation

    Yes. It's called "binding". You might want to read up on it.

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    tangerine,

    Familiar concep,t different name.

    It's been more years than I want to remember since I worked with an SQL language design team, relational database internal design and relational algebra.

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Got it now! This was a bizarre one - thanks for your help in tracing it down Jim.

    The issue is caused by the column called end which is a function name in PHP and it was incorrectly executing that function, rather than actually just using the column name!

    To fix, open php/Database/Query.php and find:

    else if ( is_callable($key) ) {
    

    in the or_where() method. Replace with:

    else if ( is_callable($key) && is_object($key) ) {
    

    and that will fix it.

    It will be in 1.6.5!

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Thank you and glad I could help.

    I'm on the road right now but will try this evening.

    One other thing I may try, since "end" is a datetime as is "start" is make them not searchable.

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    If you are using MySQL as the database, they will be searchable - but not in the format shown in the table since that is a PHP renderer, while the search happens in SQL. They will be searchable in ISO8601.

    Allan

  • obrienjobrienj Posts: 93Questions: 38Answers: 0

    Allan,

    Made you code change and all is working as it should.

    Thanks again.

    To finish up search:

    For the occasional user do you prefer/recommend:

    1. Dynamic search, i.e., repopulate the list on each search character typed OR

    2. Static search, i.e., where the repopulate only occurs once the user has entered one or more search stings and presses a button,, say "Search"

    My instinct and Usability training says static search as the user may find the dynamic search "list flashing" to be distracting to say nothing of a load on the server.

    Your thoughts please.

    Regards,
    Jim

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    For something like a DataTable, personally I like the dynamic search. It "feels" responsive (as long as it actually is - if it lags, then its horrible!).

    This is part of the reason why it is important only to enable server-side processing on tables with have tens of thousands or more rows.

    Allan

This discussion has been closed.