数据库 - 服务器端处理 - DB列合并 [英] Datatables - Server-side processing - DB column merging
问题描述
我目前正在使用DataTables 1.10.5服务器端处理功能: http:/ /www.datatables.net/examples/data_sources/server_side.html
I'm currently using DataTables 1.10.5 server-side processing feature: http://www.datatables.net/examples/data_sources/server_side.html
尚未做任何重大修改,只是插入了列名等。
Haven't done any major modifications yet, just inserted the column names, etc.
$columns = array(
array( 'db' => 'clinicaId', 'dt' => 0 ),
array( 'db' => 'rotaId', 'dt' => 1 ),
array(
'db' => 'delegadoId',
'dt' => 2,
'formatter' => function( $d, $row ) {
$delegado = new Delegado($d);
return $delegado->display('name');
}
));
所以,在我的sql表中,我有2列名为 cp4 格式:0000)和作为邮政编码一部分的 cp3 (格式:000)。
So, in my sql table, I have 2 columns called cp4 (format: 0000), and cp3 (format: 000) that are part of a postal code.
我想将这些列合并成一个在数据表上显示(格式:0000-000)。这可以通过重写我的SQL表来快速解决。但是,这样做会使分裂的目的失败,所以我可以得到它所指的具体位置,而不必爆炸。
I want to merge those columns into one, when displaying on a datatable (format: 0000-000). This could be solved quickly, by rewriting my SQL tables. But that would defeat the purpose of having them separated, so I can get the specific location it refers to without having to explode the results.
我没有找到任何具体的内容为了我的斗争已经浪费了大约2个小时,任何启发都将不胜感激。
I haven't found anything specific for my struggle. Already wasted about 2 hours on this, any enlightenment will be much appreciated.
推荐答案
尝试连接他们:
array( 'db' => '`field1`.`field2`', 'dt' => 'concatenated_fields' ),
这篇关于数据库 - 服务器端处理 - DB列合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!