Datatables server-side processing INNER JOIN or multiple tables

Below is my code without server-side processing but as it produces many rows and will grow considerably I need to use server-side processing. ---------- DB Tables (not all fields included but these are the ones i want and the fields to INNER JOIN): course_modules - id (pk), course(course.id), module(module.id), added(UNIXTIMESTAMP) course - id (pk), category(course_categories.id), fullname(text) course_categories- id (pk), name(text) modules- id (pk), name(text) I want to be able to display the UNIXTIMESTAMP as date('d/m/Y'); ---------- Would this work for the INNER JOIN $sQuery = " SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))." FROM $sTable INNER JOIN modules ON $sTable.module = modules.id INNER JOIN course ON $sTable.course = course.id INNER JOIN course_categories ON course.category = course_categories.id $sWhere $sOrder $sLimit "; ---------- Original php version without server-side processing: $mods = get_records_sql("SELECT * FROM {$CFG->prefix}course_modules"); foreach ($mods as $mod) { $thecourse = get_record('course','id',$mod->course); $themodule = get_record('modules','id',$mod->module); $thecat = get_record('course_categories','id',$thecourse->category); echo ''; echo ''.$thecat->name.''; echo ''.$thecourse->fullname.''; echo ''.$themodule->name.''; echo ''; echo date('d/m/Y', $mod->added); echo''; echo ''; } I have server-side processing woking fine with my datatables but without linking to the other tables. This table only returns IDs and I want to be able to get the value from another table as demonstrated above. Do I need to use an innner join? If so how can I incorporate with server_processing.php script: I used this one: [http://datatables.net/release-datatables/examples/data_sources/server_side.html][1] Or can I incorporate my above method within server_processing.php. Any guidance would be greatly appreciated. Thanks in advance. [1]: http://datatables.net/release-datatables/examples/data_sources/server_side.html

以上就是Datatables server-side processing INNER JOIN or multiple tables的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏