SSP.Class & WHERE Clause
SSP.Class & WHERE Clause
I am tring to figure out searching on the server sider processing. I think I am close I just can't seem to get it right
I am using the page at: https://datatables.net/manual/server-side#Example-data for assistance.
From what I gather I can filter the columns before I even display anything in the json.
Below is the code I have and I only want to return results where memberWrkGrpCode = BuildingB
Can anyone show an example on how I would do this?
// DB table to use
$table = 'members';
// Table's primary key
$primaryKey = 'memberID';
// Array of database columns which should be read and sent back to DataTables.
// The db parameter represents the column name in the database, while the dt
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => 'memberNameFirst', 'dt' => 0),
array('db' => 'memberSeniority', 'dt' => 1),
array('db' => 'memberWrkGrpCode', 'dt' => 2),
array('db' => 'memberSeniorityLastUpdate', 'dt' => 3)
);
This question has accepted answers - jump to:
Answers
You need to use the
complex
method of theSSP
class to perform a conditional query. There isn't really any examples of that, since the SSP class is really just a demo, but you can just pass the string you want to use as the query into thewhereAll
parameter.Allan
Thanks! That worked. I am going to leave some of my code here if any one wants to use it for a base.
I did also make a small change to the complex SPP Class. I removed the NULL on the function line:
```php
<?php > ``` ?><?php
static function complex($request, $conn, $table, $primaryKey, $columns, $whereResult = null, $whereAll) // Used to be $whereAll = null
{
//function content went in here
}
Nice one - thanks for posting this. One thing - PHP might throw warnings if you have a required parameter after an optional one.
Allan
I did not know that, huh, I switched them around.