Several tables added?

Several tables added?

skysky Posts: 2Questions: 0Answers: 0
edited May 2011 in DataTables 1.8
I change some of the code of server_processing to allow relations between foreign key and primary keys with several tables. Not affected normal queries. Are you interested viewing? maybe it's good enough to get included in the next version.

Sorry i didnt find other way to contact you.

Regards Me.

Replies

  • allanallan Posts: 61,439Questions: 1Answers: 10,052 Site admin
    Sounds interesting - yes please post in here as I'm sure others will find it useful.

    Allan
  • skysky Posts: 2Questions: 0Answers: 0
    edited May 2011
    Here it is. It's an example with oscommerce database products to get the products_name from products_description.

    [code]<?php
    /* 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( 'products_name', 'products_quantity', 'products_price', 'products_status', 'products_ordered' );

    /* DB tables to use */
    $aTables = array( 'products', 'products_description' );

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

    /* CONDITIONS */
    $sWhere = "WHERE products.products_id=products_description.products_id ";

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


    $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
    die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );


    /*
    * Paging
    */
    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
    $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
    mysql_real_escape_string( $_GET['iDisplayLength'] );
    }


    /*
    * Ordering
    */
    $sOrder = "";
    if ( isset( $_GET['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $i $iFilteredTotal,
    "aaData" => array()
    );

    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $row = array();
    for ( $i=0 ; $i[/code]
This discussion has been closed.