How can you use PHP editor to merge two or more tables ?

How can you use PHP editor to merge two or more tables ?

mariocart12mariocart12 Posts: 3Questions: 1Answers: 0
edited May 2017 in Free community support

How can you use PHP editor to merge 2 tables like UNION ALL?
I saw only join and leftjoin.
Using latest editor and server side procesing.
I must mention that the columns have the same name.
Could you please present an example? (looked on the documentation and forum - nothing)
Thanks Allan!

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    edited May 2017

    At the moment there is no abstraction for UNION ALL in Editor's PHP or .NET libraries I'm afraid, which is why you wouldn't find it in the documentation! One option would be to set up a suitable VIEW and then use the libraries with that.

    Regards,
    Allan

  • mariocart12mariocart12 Posts: 3Questions: 1Answers: 0

    the resolvation, but works good without server processing:

    <?php
        
        /*
            * Example PHP implementation used for the index.html example
        */
        
        // DataTables PHP library
        include( "../php/DataTables.php" );
        
        // Alias Editor classes so they are easy to use
        use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate;
        
        
        // Build our Editor instance and process the data coming from _POST
    
        $data = $db->sql( "
    SELECT id, concat('row_',id) AS DT_RowId, concat('Economisire PJ') AS tipc, prenume, judet, contact, datacreat, concat('tbl_economisire_pj') AS tabela FROM tbl_economisire_pj
    UNION ALL
    SELECT id, concat('row_',id) AS DT_RowId, concat('Economisire PF') AS tipc, prenume, judet, contact, datacreat, concat('tbl_economisire_pf') AS tabela FROM tbl_economisire_pf
    ORDER BY datacreat ASC;
    " )->fetchAll();
     echo json_encode( array(
          'data' => $data
       ) );
     
    
  • pjustindaryllpjustindaryll Posts: 13Questions: 4Answers: 0

    mariocart12 how did you set this up in table?

This discussion has been closed.