'ssp.class.php' not found

'ssp.class.php' not found

cy930cy930 Posts: 4Questions: 2Answers: 0

I am using the sample server-side script code provided in the server-side page manual of Datatables, replacing the values with my database's data. But when I try to view the JSON in the browser, I get two errors:

"Warning: require(ssp.class.php): failed to open stream: No such file or directory..."

"Fatal error: require(): Failed opening required 'ssp.class.php' (include_path='.:usr/share/php:/usr/share/pear') ... "

JS

$(document).ready(function() {

/**
 *  datatables
 */

    // create inventory datatable
    var inv_table = $('#inv_table_id').DataTable( {
        "processing": true,
        "serverSide" : true,
        "ajax" : {
            url: 'inv_ajax.php',
            type: 'post'
        },
        "select" :  true,
        "sAjaxDataProp": "",
        "dom" : 'Bfrtip',
        "buttons" : [
            // default buttons of DT
            'copy', 'excel', 'pdf'
        ],
        "aoColumns": [
            {"mData": "product"},
            {"mData": "supplier_name"},
            {"mData": "category"},
            {"mData": "unit_price"},
            {"mData": "retail_price"}
        ]
    });
    
    // add buttons to inventory table (because of Bootstrap integration)
    inv_table.buttons().container()
        .appendTo($('.col-sm-6:eq(0)', inv_table.table().container() ));

I am not sure whether to use "bprocessing" or "processing", "sAjaxSource" or "ajax", "aoColumns" or "columns" because I've seen samples using both and I'm confused.

PHP (copy of server-side script with my some of my database's details)

<?php
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */
 
// DB table to use
$table = 'inventory';
 
// Table's primary key
$primaryKey = 'id';
 
// 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 object
// parameter names
$columns = array(
    array( 'db' => 'product', 'dt' => 'product' ),
    array( 'db' => 'supplier_name',  'dt' => 'supplier_name' ),
    array( 'db' => 'category',   'dt' => 'category' ),
    array( 'db' => 'unit_price',     'dt' => 'unit_price' ),
    array( 'db' => 'retail_price',     'dt' => 'retail_price' ),
    
);
 
// SQL server connection information
$sql_details = array(
    'user' => '******',
    'pass' => '******',
    'db'   => '******',
    'host' => '******'
);
 
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
 
require( 'ssp.class.php' );
 
echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

As far as I know, I need to use the server-side option of Datatables in order to use Editor's server side option(?) That way, any modification or addition that the user makes would also be recorded in the database right..?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,998Questions: 1Answers: 10,371 Site admin

    As far as I know, I need to use the server-side option of Datatables in order to use Editor's server side option(?)

    No - don't use the SSP class at all if you are using Editor. Editor's own libraries have built in support for server-side processing and will automatically detect a server-side processing request - example.

    Allan

  • cy930cy930 Posts: 4Questions: 2Answers: 0

    Hi Allan,
    right now I'm not using Editor just yet. I'm only trying out the server-side functionality of DataTables first, but I'll sure to keep your advice in mind when I use the Editor!

    I guess my question still remains the same though. I'm assuming that the sample script is enough to generate a similar ajax accompanied by it in the examples page. So If I'm using DataTables without the Editor, how can I make the code work with ssp.class.php? Is it something I need to include in the Download Builder? Or do I need to add something else in the script?

  • dclar43dclar43 Posts: 47Questions: 13Answers: 2
    edited December 2015 Answer ✓

    You'd have to give some more information about your set up. But what I'm assuming you did is copy the "server-side-script" from this example

    As you've found out that won't take care of the require( 'ssp.class.php' ); statement. You need to download the full DataTables package found here. ssp.class.php can be found in examples/server_side/scripts.

    If you extract the archive you've downloaded to a server of some sort you can browse to /examples to view a local version of DataTable's examples. Though for the server-side stuff you'll need to have some SQL server set up(the scripts directory has .sql files to populate the database for you).

  • cy930cy930 Posts: 4Questions: 2Answers: 0

    Thanks @dclar43! I downloaded the files using the download builder, so the 'ssp.class.php' is probably not included in it.

  • allanallan Posts: 62,998Questions: 1Answers: 10,371 Site admin

    That is correct. You can get it from GitHub directly if you don't want to download the full package.

    Allan

This discussion has been closed.