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

Detailed explanation of the problems and solutions caused by floating elements

1. Problem Multiple floating elements cannot expa...

Summary of various postures of MySQL privilege escalation

Table of contents 1. Write Webshell into outfile ...

Solution to find all child rows for a given parent row in MySQL

Preface Note: The test database version is MySQL ...

MySQL 8.0.23 installation super detailed tutorial

Table of contents Preface 1. Download MySQL from ...

Three ways to communicate between React components (simple and easy to use)

Table of contents 1. Parent-child component commu...

Nodejs converts JSON string into JSON object error solution

How to convert a JSON string into a JSON object? ...

mysql workbench installation and configuration tutorial under centOS

This article shares the MySQL Workbench installat...

Summary of considerations for writing web front-end code

1. It is best to add a sentence like this before t...

HTML tag ID can be a variable

<table id=" <%=var1%>">, the...

Summary of four ways to loop through an array in JS

This article compares and summarizes four ways of...

How to use Web front-end vector icons

Preface When writing front-end pages, we often us...

Common structural tags in XHTML

structure body, head, html, title text abbr, acro...