getdata table table data join mysql method

getdata table table data join mysql method
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:

$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 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

$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 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:
  • Several solutions for forgetting the MySQL password
  • Tomcat+Mysql high concurrency configuration optimization explanation
  • Why does MySQL database index choose to use B+ tree?
  • Explanation of MySQL's horizontal and vertical table partitioning
  • Detailed explanation of how to use CMD command to operate MySql database
  • MySQL 5.6 root password modification tutorial
  • Solutions to MySql crash and service failure to start
  • Tutorial on how to modify the root password in MySQL 5.7
  • Several ways to update batches in MySQL
  • Summary of the differences between MySQL storage engines MyISAM and InnoDB

<<:  vsCode generates vue templates with one click

>>:  Installation process of CentOS8 Linux 8.0.1905 (illustration)

Recommend

Implementation of Vue counter

Table of contents 1. Implementation of counter 2....

A record of pitfalls in JS regular matching

I recently discovered a pitfall in regular expres...

Basic syntax of MySQL index

An index is a sorted data structure! The fields t...

Install JDK1.8 in Linux environment

Table of contents 1. Installation Environment 2. ...

How to quickly copy large files under Linux

Copy data When copying data remotely, we usually ...

MySQL restores data through binlog

Table of contents mysql log files binlog Binlog l...

Tomcat configuration and how to start it in Eclipse

Table of contents How to install and configure To...

Talking about ContentType(s) from image/x-png

This also caused the inability to upload png files...

XHTML Getting Started Tutorial: Simple Web Page Creation

Create your first web page in one minute: Let'...

How to run .sh files in Linux system

There are two ways to run .sh files in Linux syst...

Detailed explanation of Vue custom instructions

Table of contents Vue custom directive Custom dir...

Summary of Docker Consul container service updates and issues found

Table of contents 1. Container service update and...

Rendering Function & JSX Details

Table of contents 1. Basics 2. Nodes, trees, and ...

How to separate static and dynamic state by combining Apache with Tomcat

Experimental environment Apache and Tomcat are bo...