ds11111111111111111 2019-05-12 11:54
浏览 76

使用服务器端方法将一行数据表分成多行

I have a mysql table that store all info about customer supports like smsPanel,website,vmodule,.....

customerName|smspanel|SMSstartDay|SMSexpDay |websit|WebStartDay|webExpDay|
------------------------------------------------------------
john        |yes     |2019/01/15 |2020/01/15|yes   |2019/02/12 |2020/02/12

I am using datatable serverside method to show informations. Its ok when I show every single row of database in single row of data table. but i want to show every support package in different row lik this

customerName  |  package | StartDay  | EndDate
----------------------------------------------
jhon          | SMS      |2019/01/15 |2020/01/15
jhon          | website  |2019/02/12 |2020/02/12

this is my sql query for datatable serverSide

if($ssaction == "customerSupportlist"){
$table = <<<EOT
 (
    SELECT
    *
    FROM pdsupport
    where customer_smsPack >0
 ) temp
EOT;
}

and i use this cod to format datatable but its useful for one row display

if($ssaction == "customerSupportlist"){
    $primaryKey='id';

$columns = array(
    array( 'db' => 'customer_fname','dt' => 0),
    array( 'db' => 'customer_lname',  'dt' => 1 ),


    array('db' => 'customer_ncode','dt' => 2),
    array('db' => 'customer_mobile','dt' => 3),  
     array( 'db' => 'id',
          'dt' => 4,
            'formatter' =>function( $d, $row ) {
            $customerPacks=getCustomerPacks($d);
           return   $customerPacks;
        }

           ),    
         array( 'db' => 'id',
          'dt' => 5,
            'formatter' =>function( $d, $row ) {
            $startDate=getCustomerPackStartDate($d);
           return   $startDate;
        }

           ),
     array( 'db' => 'id',
          'dt' => 6,
            'formatter' =>function( $d, $row ) {
            $endDate=getCustomerPackEndDate($d);
           return   $endDate;
        }

           ),
      array( 'db' => 'id','dt' => 7 ),


);
}

I dont know how to modify this part to split the rows. OR by changing mysql query make a table that has my favorite structure

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 SQL Server下载
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
    • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
    • ¥15 python爬取bilibili校园招聘网站
    • ¥30 求解达问题(有红包)
    • ¥15 请解包一个pak文件
    • ¥15 不同系统编译兼容问题
    • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
    • ¥30 数字电源对DSP芯片的具体要求