*.list.php: how get records from an SQL query instead of a table

Discussion in 'Developers' Forum' started by caudatus, Nov 28, 2011.

  1. caudatus

    caudatus New Member

    Dear Till!


    It's the first time when I can say a big thank for this great admin sw, "ispconfig"!

    Could You tell me,
    that Is it possible in *.list.php files to get records from an SQL select query instead of a simple table ?

    To define the record source by default the form (with an example table) is:

    $liste["table"] = "mail_forwarding";

    It would be nice to create merged lists, for example primary and secondary dns zones in one list.

    Thank You very much!

    Janos
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Each list object in ISPConfig is based on the class listform_actions. The listform actions can be found in interface/lib/classes/listform_actions.inc.php file. This class contains a function named getQueryString() which returns the sql string that is used to display the list. To show lists with a more complex sql syntax, you can override the function getQueryString() in your custom list file.

    Example:

    Code:
    $app->load('listform_actions');
    
    class list_action extends listform_actions {
    	
    	function getQueryString(){
                    $my_sql_query = "SELECT * FROM a,b WHERE ......";
                    return $my_sql_query;
    
    	}
    	
    }
    
    $list = new list_action;
    $list->onLoad();
    
     
: table, sql, list.php

Share This Page