Serverside processing and joins

Serverside processing and joins

renevanhrenevanh Posts: 13Questions: 1Answers: 0
edited May 2015 in Free community support

I'm using the serverside processing script (https://datatables.net/development/server-side/php_mysql) to handle a big dataset and it's working fine.

Now the client wants some extra data displayed that's in different tables of the database. I'd need to use a join to achieve this.
i've tried some things, but I can't seem to figure out how I'd incorperate the constrains for this join (or the join itself for that matter) into the serverside script.

Any help would be appriciated greatly!

Answers

  • renevanhrenevanh Posts: 13Questions: 1Answers: 0

    No suggestions? I'm pretty stuck :(

  • joejordanbrownjoejordanbrown Posts: 2Questions: 0Answers: 0
    edited May 2015

    ssp.class.php on line 243 change

    "SELECT SQL_CALC_FOUND_ROWS ".implode(", ", self::pluck($columns, 'db'))."

    to

    "SELECT SQL_CALC_FOUND_ROWS ".implode(", ", self::pluck($columns, 'db'))."
    

    then in your server_processing.php

    // DB use for one table
    $table = 'table1';
    
    // DB use formatting for multi tables
    $table = 'table1`, `table2';
    
    // Table's primary key
    $primaryKey = 'table1key';
    
    $columns = array(
        array( 'db' => 'coltable1id', 'dt' => 0 ),
        array( 'db' => 'coltable1name', 'dt' => 1 ),
        array( 'db' => 'coltable2house', 'dt' => 2 ),
    
    $whereResult = "table1.id = table2.id";
    

    That's how I've just manged to link 2 tables. Let me know if you have any problems.

  • renevanhrenevanh Posts: 13Questions: 1Answers: 0

    Thanks, I'll give it a try!

  • joejordanbrownjoejordanbrown Posts: 2Questions: 0Answers: 0

    Did that work for you?

  • renevanhrenevanh Posts: 13Questions: 1Answers: 0

    Not had time to return to this project yet, hope to get around it this week.
    I'll tell if it worked of not!

  • OwaisOwais Posts: 1Questions: 0Answers: 0

    Hello joejordanbrown,

    well i have tried your example but its not working for me. when i give column id to table1.id its says error in sql.

    please help me out

    Thanks

This discussion has been closed.