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)
1. Problem Multiple floating elements cannot expa...
Table of contents 1. Write Webshell into outfile ...
Nginx is a high-performance website server and re...
Preface Note: The test database version is MySQL ...
Table of contents Preface 1. Download MySQL from ...
Table of contents 1. Parent-child component commu...
How to convert a JSON string into a JSON object? ...
This article shares the MySQL Workbench installat...
1. It is best to add a sentence like this before t...
<table id=" <%=var1%>">, the...
This article compares and summarizes four ways of...
1. In addition to the default port 8080, we try t...
Preface When writing front-end pages, we often us...
Table of contents 1. Schematic diagram of group q...
structure body, head, html, title text abbr, acro...