* [ ] 功能
* 用于合并兩個或多個 SELECT 語句的結果集
* 支持多次連貫調用
* 參數
| 參數名 | 參數類型 | 參數說明 | 默認值 |
| :---: | :---: | :---: | :---: |
| $data | array | select語句集合,當數組的 key 不為數字的時候,會命名該組合查詢的別名 | 必傳 |
| $type | bool | —— | 默認 false |
* 場景:user 數據庫的 user_account_1 表只有 2 條數據,user_account_2 表有數據 1 條:
user_account_1 表
| uid | username |
| :---: | :---: |
| 1 | 張三 |
| 2 | 李四 |
user_account_2 表
| uid | username |
| :---: | :---: |
| 3 | 隔壁老王 |
* 用法:
~~~
// 獲取查詢表的 sql 語句
$table_select_sql = [];
$table_select_sql[] = mysql\User::tabname('account_1', '*');
$table_select_sql[] = mysql\User::tabname('account_2', '*');
// 聯合查詢別名命名為 union_account
$data = mysql\User::union( ['union_account' => $table_select_sql], true )->select();
~~~
執行的 sql 語句:
~~~
select?*?from?(select?*?from?user.user_account_1?union?select?*?from?user.user_account_2)?as?union_account
~~~
查詢結果:
~~~
array(
array(
'uid' => 1,
'username' => '張三',
),
array(
'uid' => 2,
'username' => '李四',
),
array(
'uid' => 3,
'username' => '隔壁老王',
),
);
~~~
- 開始使用
- 配置文件
- 路由模式
- AutoLoad類
- 啟動文件
- __construct
- SetRouting
- SetAlias
- SetStop
- SetError
- Access
- SetWorker
- SetClassFile
- SetClassDir
- Run
- OpenLoad
- LinuxStartAll
- Session類
- 使用說明
- set
- get
- delete
- pull
- has
- id
- Cookie類
- 使用說明
- set
- get
- delete
- pull
- has
- TempLets類
- 模板語法
- 模板標簽
- html
- show
- assign
- obtain
- Request類
- get
- post
- host
- referer
- getip
- localip
- header
- body
- file
- scheme
- protocolversion
- uri
- path
- querystring
- method
- Response
- SendFile
- FileStream
- SendData
- SetStatus
- SetHead
- SetMime
- WebSend
- redirect
- dumpJson
- dump
- come
- ps
- Frame類
- GetWeb
- ViewFile
- RoutingData
- SetClassFile
- SetClassDir
- GetMime
- FileMime
- LoadDir
- StartDir
- IsJson
- ArrJson
- JsonFormat
- ObStart
- GetConfig
- ConfigDir
- TempDir
- GetRunData
- GetStatic
- IsDebug
- SetDebug
- GetDebugInfo
- GlobalVariables類
- 使用說明
- set
- get
- delete
- pull
- has
- id
- Mysql類
- 新版本
- 第三方
- Thinkorm
- Medoo
- 舊版本
- Mysql 配置格式
- 項目中操作數據庫
- 項目場景
- 項目數據庫配置
- 項目數據庫中間類
- 項目中操作數據表
- 連貫操作
- where
- table
- data
- order
- field
- limit
- page
- group
- having
- join
- tabname
- union
- sql
- link
- link_base
- lock
- CURD 操作
- 寫入數據
- 數據刪除
- 數據查詢
- 數據更新
- 數據統計操作
- count
- sum
- max
- min
- avg
- 操作DEMO
- CurdTrait.php
- 項目Model層操作表.md
- Curl類
- Method類
- SslAes類
- layui_zqadmin