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']){//Open online ordering $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:
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 username$term1 = $_M[form]['search_title']; //Get search keywords$search1 = $term1 ?"and username like '%{$term1}%' ":'';//Add query registration form number$table = load::sys_class('tabledata', 'new'); //$where = "lang='cn' {$search} {$search1}"; //Add query condition $search to the conditional statement $u = $_M['table']['user']; $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.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('Ymd H:i:s',time()); foreach($array as $key => $val){ //Member group $rs_user_group=DB::get_one("SELECT id,name FROM ".$_M['table']['user_group']." where id='$val[groupid]' "); //Status//Class type//$rs1=DB::get_all("SELECT s.class_id,a.user_id,a.id,a.number,cc.classhour FROM ".$_M['table']['my_application']." as a INNER JOIN ".$_M['table']['my_application_subject']." as s 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_id<>0 and s.type_11=0 and c.teachers_id='$val[id]' and cc.endtime>'$time'"); $list = array(); $list[] = "{$val['username']}"; $list[] = "{$rs_user_group['name']}"; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = "<a class='btn btn-danger view_error' lay-id='{$val['id']}' href='javascript:;'><i class='glyphicon glyphicon-edit'></i> Wrong Question Collection</a>"; $list[] = ""; $list[] = ""; $rarray[] = $list; } // dump($rarray); $table->rdata($rarray); //Return data} Example 2: join find_in_set
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 username$term1 = $_M[form]['search_title']; //Get search keywords$search1 = $term1 ?"and username like '%{$term1}%' ":'';//Add query registration form number$table = load::sys_class('tabledata', 'new'); //$where = "lang='cn' {$search} {$search1}"; //Add query condition $search to the conditional statement $u = $_M['table']['user']; //$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('Ymd H:i:s',time()); foreach($array as $key => $val){ //Member group $rs_user_group=DB::get_one("SELECT id,name FROM ".$_M['table']['user_group']." where id='$val[groupid]' "); //Status//Class type//$rs1=DB::get_all("SELECT s.class_id,a.user_id,a.id,a.number,cc.classhour FROM ".$_M['table']['my_application']." as a INNER JOIN ".$_M['table']['my_application_subject']." as s 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_id<>0 and s.type_11=0 and c.teachers_id='$val[id]' and cc.endtime>'$time'"); $list = array(); $list[] = "{$val['username']}"; $list[] = "{$rs_user_group['name']}"; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = ""; $list[] = "<a class='btn btn-danger view_error' lay-id='{$val['id']}' href='javascript:;'><i class='glyphicon glyphicon-edit'></i> Wrong Question Collection</a>"; $list[] = ""; $list[] = ""; $rarray[] = $list; } // dump($rarray); $table->rdata($rarray); //Return data} Notice: 1. List all 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}%' "; Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: vsCode generates vue templates with one click
>>: Installation process of CentOS8 Linux 8.0.1905 (illustration)
Table of contents Time zone configuration in Djan...
How to view version information under Linux, incl...
like LIKE requires the entire data to match, whil...
Table of contents 1. Introduction 2. Self-increme...
This article example shares the specific code of ...
Table of contents 1. Scenario 2. Basic functions ...
Table of contents background Effect Ideas backgro...
1. Write the Dockerfile (1) Right-click the proje...
Table of contents Problem scenario: Solution: 1. ...
Preface This article aims to explain the most bor...
In MySQL, create a view on two or more base table...
MySQL Bin log data recovery: accidentally delete ...
Table of contents Preface: 1. Default value relat...
Referring to other more professional blog systems...
In Docker's design, a container runs only one...