search is not happening in server side script when i return the values

search is not happening in server side script when i return the values

SandeepMuralaSandeepMurala Posts: 30Questions: 8Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • SandeepMuralaSandeepMurala Posts: 30Questions: 8Answers: 0

    Hi,
    I am working on datatable server side scrpting (server.php and ssp.class.php) ,

    in server.php this is my code

    $columns = array(
        array( 'db' => 'lead_id', 'dt' => 0 ),
        array( 'db' => 'lead_id', 'dt' => 1 ,'formatter' => function( $d, $row ) 
        {
            $hostname='localhost';
            $user = 'root';
            $password = 'test';
            $mysql_database = 'testDB';
            $link1 = mysqli_connect($hostname, $user, $password,$mysql_database);
            
                    
            $sql3 = "select user,phone_number,first_name from Test where lead_id='$d'";  
            $res3 = mysqli_query($link1,$sql3);
            $rows3=mysqli_fetch_row($res3);
            
            $login_UserVal = $rows3[0];
            $phone_numberVal = $rows3[1];
            $first_nameVal = $rows3[2];
            
            return "<a onclick='window.open(\"user_profile.php?user=$login_UserVal&phone=$phone_numberVal&leadId=$d\")'>$first_nameVal</a>";            
        },
        ),
        array( 'db' => 'field1',  'dt' => 2 ),
        array( 'db' => 'field12',  'dt' => 3 ),
        array( 'db' => 'field2',  'dt' => 4 ),
        array( 'db' => 'field3',  'dt' => 5 ),
        array( 'db' => 'field4',  'dt' => 6 ),
        array( 'db' => 'field5',  'dt' => 7 ),
        array( 'db' => 'field6',  'dt' => 8 ),
        array( 'db' => 'city',  'dt' => 9 ),
        array( 'db' => 'field10',  'dt' => 10 ),
        array( 'db' => 'user',  'dt' => 11 )
    )
    

    Here index 1 column i am returning the value form another table ,
    So when I do global search this index 1 column not happening remaining columns i am doing search .

    This issue i did face earlier also but I did not know how to fix it ,So when I return any of the column that particuler column I am unable to gobal serach .

    How can I fix this issue ,kindly help on it .

    Thanks
    Sandeep

  • SandeepMuralaSandeepMurala Posts: 30Questions: 8Answers: 0

    Could any one suggest on it please ?

  • allanallan Posts: 54,712Questions: 1Answers: 8,558 Site admin

    That looks like an extremely inefficient way of doing it I'm afraid. For every row in the table you are making a new database connection and running a query. Side from not being able to search in that column, the script will start to run really slowly.

    What you need is a left join. The demo SSP script doesn't support joins, but Editor's PHP libraries do and you can use them free (i.e. without an Editor license) as described here.

    If you don't want to use the Editor libraries, then you need to modify the SSP class to do a left join.

    Allan

  • SandeepMuralaSandeepMurala Posts: 30Questions: 8Answers: 0

    @allan ,Thank you so much for your valuable time and I realy appreciated ,

    Could you explain how can I modify the SSp class to do left join .

    And I don't know how to to editer libraries ,so plz expain little bit on SSP class left join.

    Thanks
    Sandeep.

  • allanallan Posts: 54,712Questions: 1Answers: 8,558 Site admin

    Hi Sandeep,

    This is the class in question. You would need to modify it to add left join support. I'm afraid that is not something I can offer to do at the moment.

    Allan

Sign In or Register to comment.