how to use a lot of tables from database in DataTables

how to use a lot of tables from database in DataTables

crossxcrossx Posts: 4Questions: 0Answers: 0
edited September 2011 in DataTables 1.8
Hello All,
I'm newbie using datatables, and I have problem how to use a multiple tables for INNER JOIN, from the example below;

<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/

/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'engine', 'browser', 'platform', 'version', 'grade' );

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";

/* DB table to use */
$sTable = "ajax"; <------------- this is what I mean, what if I want to use an inner join

/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "localhost";


< ......... >

echo json_encode( $output );
?>

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    $sTable in this script is not necessary. It's there for convenient editing for the simple case of a reading from a single table. If you're doing more complicated joins, ignore $sTable and get to the heart of things down below where $sQuery is defined. Any valid SQL will work fine.
  • crossxcrossx Posts: 4Questions: 0Answers: 0
    hi, fbas.. tks for u'r support.. I will try do this n I will need u again if this not working... tks again
  • crossxcrossx Posts: 4Questions: 0Answers: 0
    hi fbas..can you show me, how to modify $sQuery.. because I can't find how to make this variable to fine working, and I still find error "Json Data from server could not be parsed..."
    thanks before for attention..
  • crossxcrossx Posts: 4Questions: 0Answers: 0
    hi fbas , I've managed to do it ... thank you once again for your help
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    excellent. I was going to have to charge you for my services if you made me write the whole thing. =D
This discussion has been closed.