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

Time zone issues with Django deployed in Docker container

Table of contents Time zone configuration in Djan...

How to view version information in Linux

How to view version information under Linux, incl...

Commonplace talk about the usage of MYSQL pattern matching REGEXP and like

like LIKE requires the entire data to match, whil...

Why is the MySQL auto-increment primary key not continuous?

Table of contents 1. Introduction 2. Self-increme...

js implements a simple shopping cart module

This article example shares the specific code of ...

JavaScript Sandbox Exploration

Table of contents 1. Scenario 2. Basic functions ...

How to clear the validation prompt in element form validation

Table of contents Problem scenario: Solution: 1. ...

Why is your like statement not indexed?

Preface This article aims to explain the most bor...

How to create a view on multiple tables in MySQL

In MySQL, create a view on two or more base table...

How to set the default value of a MySQL field

Table of contents Preface: 1. Default value relat...

Add a copy code button code to the website code block pre tag

Referring to other more professional blog systems...

Solve the problem of managing containers with Docker Compose

In Docker's design, a container runs only one...