Jump to content

BosstonKUKU

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by BosstonKUKU

  1. Sorry sir for not being more specific. What i am building now is a dynamic report in php using PDO format and i am using MySQL Multi Column cross Tabulation AKA pivot table. But the problem is how i can apply this query in PHP PDO format.

     

    This is my current progress.

    try{
        $handler = new PDO('mysql:host=localhost;dbname=DatabaseName','Username','Password');
        $handler ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
     }catch(PDOException $e){
         die($e->getMessage());
    }
    
     $query = $handler->query (
    
    "Select TransactionType,TransactionCount From dummy_transaction"

     

    );
    
        while($row = $query->fetch()){
           echo $row['TransactionType'], echo $row['TransactionCount'], '<br>';
    
    
    }
    

    But i don't have any idea on how to deal with this query and apply in PHP PDO format. Something like i am dealing in multi-query. Any advice sir well appreciated. And thank you for the reply. 

  2. I have existing query which successfully output  a dynamic table using pivot. But the problem is i have no idea how to apply this in PDO format in php. Any help please.

     

     

     

    SELECT GROUP_CONCAT(DISTINCT CONCAT('SUM(IF(DateTransact = ''',DateTransact,''', TransactionCount, NULL))' ))

                          

                        INTO @sql 

                        FROM dummy_transaction;

     

                        SET @sql = CONCAT('SELECT TransactionType, ', @sql, ' FROM dummy_transaction GROUP BY TransactionType  ');

     

                        PREPARE stmt FROM @sql;

                        EXECUTE stmt;

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.