当前位置:网站首页>Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
2022-07-06 22:47:00 【Dehong eye inserting demon king】
Database only 
Want to achieve :
Code up :
public function demo()
{
// With shop Main table
$res = Db::table('shop')
->alias("a") // Take an alias
// And shop_class Tables are associated , The name i, also a Tabular shop_class Field equals i Tabular class_code Field
// Table 1 and table 2 are the same :'a.shop_class = i.class_code'
->join('shop_class i', 'a.shop_class = i.class_code')
->field('a.id,a.shop_name,a.shop_price,a.shop_details,i.class_name,a.shop_src,a.shop_xq_src1,a.shop_xq_src2,a.shop_xq_src3,a.good_unit,a.good_parameter,a.good_specs_code')
// Query required fields field()
->select();
//->paginate(10);// If you need to add this paragraph by page
var_dump($res);
}
边栏推荐
- 服务器的系统怎么选者
- 树的先序中序后序遍历
- Aardio - 通过变量名将变量值整合到一串文本中
- European Bioinformatics Institute 2021 highlights report released: nearly 1million proteins have been predicted by alphafold
- memcached
- Mysql 身份认证绕过漏洞(CVE-2012-2122)
- 【编译原理】做了一半的LR(0)分析器
- NPM cannot install sharp
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- 2014阿里巴巴web前实习生项目分析(1)
猜你喜欢

Method of canceling automatic watermarking of uploaded pictures by CSDN

Aardio - integrate variable values into a string of text through variable names

【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件

Rust knowledge mind map XMIND

【LeetCode】19、 删除链表的倒数第 N 个结点

Signed and unsigned keywords

CocosCreator+TypeScripts自己写一个对象池

Mysql database basic operations DML

Matlab tips (27) grey prediction

uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
随机推荐
视图(view)
three. JS gorgeous bubble effect
BasicVSR_ Plusplus master test videos and pictures
UVa 11732 – strcmp() Anyone?
机试刷题1
SQL server generates auto increment sequence number
Windows Auzre 微软的云计算产品的后台操作界面
Aardio - Method of batch processing attributes and callback functions when encapsulating Libraries
memcached
Clip +json parsing converts the sound in the video into text
On the problems of born charge and non analytical correction in phonon and heat transport calculations
The ceiling of MySQL tutorial. Collect it and take your time
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
Void keyword
QT信号和槽
TypeScript获取函数参数类型
动作捕捉用于蛇运动分析及蛇形机器人开发
使用云服务器搭建代理
Typescript get function parameter type
[IELTS speaking] Anna's oral learning record part1