Subselect SQL Use sql to generate dynamic columns (Added in version 4.4)

You can use the subselect query to generate columns dynamically. You can get data from other tables using the query. It accepts two parameters, first one is column name/alias and second is query.

  
                                $pdocrud = new PDOCrud();
                                $pdocrud->crudTableCol(array("first_name","last_name"));
                                 /**
                                 * Allows you to add the dynamic column based on sub query
                                 * @param   string   $columnName                      Alias column name to be used for the query
                                 * @param   string   $query                           Sub Query to be used
                                 * return   object                                    Object of class
                                 */
                                $pdocrud->subQueryColumn("order_id", "select sum(id) from orders where customer_name = {user_name}");
                                echo $pdocrud->dbTable("users")->render(); 
                                

Users

Showing 1 to 10 of 1200 entries

# First name Last name Order id Actions
1 Jon Snow
2 Dev Smith
3 fnaPBiAtreBQOk KqujHfsnFThgqaosaUI
4 fnaPBiAtreBQOk KqujHfsnFThgqaosaUI
5 fnaPBiAtreBQOk KqujHfsnFThgqaosaUI
6 fnaPBiAtreBQOk KqujHfsnFThgqaosaUI
7 TKDYMgTkoYDHEG nKMYNgOnWbkqLC
8 TKDYMgTkoYDHEG nKMYNgOnWbkqLC
9 TKDYMgTkoYDHEG nKMYNgOnWbkqLC
10 TKDYMgTkoYDHEG nKMYNgOnWbkqLC
# First name Last name Order id Actions