Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of join mysql method for getdata table tabular data

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you the "getdata table tabular data join mysql method example analysis", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "getdata table tabular data join mysql method example analysis" this article.

Public function json_product_list ($where, $order) {global $_ M; $this- > table = load::sys_class ('tabledata',' new'); $p = $_ M ['table'] [' product']; $s = $_ M ['table'] [' shopv2_product']; if ($_ M ['config'] [' shopv2_open']) {/ / when online ordering is opened, $table = $p.' Left JOIN'. $s. " ON ({$p} .id = {$s} .pid) "; $where =" {$p} .Lang ='{$_ M ['lang']}' and ({$p} .recycle ='0' or {$p} .recycle ='- 1') {$where} ";} else {$table = $p; $where =" lang=' {$_ M ['lang']}' and (recycle ='0' or recycle ='- 1') {$where} " } $data = $this- > table- > getdata ($table,'*', $where, $order); foreach ($data as $key= > $val) {if (! $val ['pid']) $data [$key] [' pid'] = $val ['id'];} return $data;}

Example 1:

$u = $_ M ['table'] [' user']

$o = $_ M ['table'] [' shopv2_order']

$d = $u.' Left JOIN'. $o. "ON {$u} .id = {$o} .uid"

Function dotable_course_user_list_json () {global $_ M; $id=$_ M [form] ['id']; / teacher module ID $tid=$_ M [form] [' tid']; / teacher login user ID $tn=$_ M [form] ['tn']; / / teacher user name $term1 = $_ M [form] [' search_title'] / / get the search keywords $search2 = $term1? "and username like'% {$term1}%'":''; / / add the query registration form number $table = load::sys_class ('tabledata',' new'); / / $where = "lang='cn' {$search} {$search2}"; / / add the query condition $search $u = $_ M ['table'] [' user'] to the conditional statement $o = $_ M ['table'] [' shopv2_order']; $d = $u.' Left JOIN'. $o. "ON {$u} .id = {$o} .uid"; / / $table = $u.' Left JOIN'. $a. " ON (find_in_set (u.iddcent a.userSecretid)! = 0) "; $where =" {$u} .Lang ='{$_ M ['lang']}' "; $order =" {$u} .id DESC "; $array = $table- > getdata ($d,'*', $where, $order); / / $data = $this- > table- > getdata ($table,'*', $where, $order) / / $time=date ('Y-m-d HRARIA) Foreach ($array as $key = > $val) {/ / member group $rs_user_group=DB::get_one ("SELECT id,name FROM". $_ M ['table'] [' user_group']. " Where id='$ valu [groupid]'"); / / status / / shift type / / $rs1=DB::get_all (" SELECT s.classclassidlement a.userclassiid a.idmathea.numbermage cc.classhour FROM ". $_ M ['table'] [' my_application']." As an INNER JOIN ". $_ M ['table'] [' my_application_subject']." Ass ON a.number=s.number INNER JOIN ". $_ M ['table'] [' my_class']." As c ON s.class_id=c.id INNER JOIN ". $_ M ['table'] [' my_class_course']." As cc ON cc.class_id=c.id where s.class_id0 and s.type_11=0 and c. TeachersSecretidships $validate [id] 'and cc.endtime >' $time' "); $list = array (); $list [] =" {$val ['username']} "; $list [] =" {$rs_user_group [' name']} "; $list [] ="; $list [] =" $list [] = ""; $list [] = "wrong problem set"; $list [] = ""; $list [] = ""; $rarray [] = $list;} / / dump ($rarray); $table- > rdata ($rarray); / / return data}

Example 2: join find_in_set

$u = $_ M ['table'] [' user']

$a = $_ M ['table'] [' my_application']

$d = $u.' Left JOIN'. $a. "ON find_in_set ({$u} .id, {$a} .user _ id)! = 0"

Function dotable_course_user_list_json () {global $_ M; $id=$_ M [form] ['id']; / teacher module ID $tid=$_ M [form] [' tid']; / teacher login user ID $tn=$_ M [form] ['tn']; / / teacher user name $term1 = $_ M [form] [' search_title'] / / get the search keywords $search2 = $term1? "and username like'% {$term1}%'":''; / / add the query registration form number $table = load::sys_class ('tabledata',' new'); / / $where = "lang='cn' {$search} {$search2}"; / / add the query condition $search $u = $_ M ['table'] [' user'] to the conditional statement / / $o = $M ['table'] [' shopv2_order']; $a = $_ M ['table'] [' my_application']; / / $d = $u.' Left JOIN'. $o. "ON {$u} .id = {$o} .uid"; $d = $u.' Left JOIN'. $a. " ON find_in_set ({$u} .id, {$a} .user _ id)! = 0 "; $where =" {$u} .Lang ='{$_ M ['lang']}' "; $order =" {$u} .id DESC "; $array = $table- > getdata ($d,'*', $where, $order); / / $data = $this- > table- > getdata ($table,'*', $where, $order) / $time=date ('Y-m-d Hpurs) Foreach ($array as $key = > $val) {/ / member group $rs_user_group=DB::get_one ("SELECT id,name FROM". $_ M ['table'] [' user_group']. " Where id='$ valu [groupid]'"); / / status / / shift type / / $rs1=DB::get_all (" SELECT s.classclassidlement a.userclassiid a.idmathea.numbermage cc.classhour FROM ". $_ M ['table'] [' my_application']." As an INNER JOIN ". $_ M ['table'] [' my_application_subject']." Ass ON a.number=s.number INNER JOIN ". $_ M ['table'] [' my_class']." As c ON s.class_id=c.id INNER JOIN ". $_ M ['table'] [' my_class_course']." As cc ON cc.class_id=c.id where s.class_id0 and s.type_11=0 and c. TeachersSecretidships $validate [id] 'and cc.endtime >' $time' "); $list = array (); $list [] =" {$val ['username']} "; $list [] =" {$rs_user_group [' name']} "; $list [] ="; $list [] =" $list [] = ""; $list [] = "wrong problem set"; $list [] = ""; $list [] = ""; $rarray [] = $list;} / / dump ($rarray); $table- > rdata ($rarray); / / return data}

Note:

1. List all the data

$data = $this- > table- > getdata ($table,'*', $where, $order)

2. List only the specified field data

$array = $table- > getdata ($d, "{$u} .username, {$u} .groupid", $where, $order)

3. Fuzzy query

$where = "{$u} .lang ='{$_ M ['lang']}' and {$u} .username like'% {$term1}%'"; the above is all the contents of the article "sample Analysis of getdata table tabular data join mysql methods". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report