thinkPHP的資料庫操作怎麼用alias?

來源:互聯網
上載者:User
連貫操作 作用 支援的參數類型
alias 用於給當前資料表定義別名 字串

求助thinkPHP的操作方式alias怎麼用,不要原生態的sql寫法
thinkPHP的開發文檔裡面介紹是不是漏了alias的介紹?我的是thinkPHP3.1.2的開發文檔


回複討論(解決方案)

請遵守CSDN使用者管理辦法,不得違反國家法律法規。

http://www.thinkphp.cn/simple/quickstart_4.html

alias用於設定當前資料表的別名,便於使用其他的連貫操作例如join方法等。樣本:$Model = M('User');$Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();最終產生的SQL語句類似於:SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id
http://document.thinkphp.cn/manual_3_2.html#alias

alias用於設定當前資料表的別名,便於使用其他的連貫操作例如join方法等。樣本:$Model = M('User');$Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();最終產生的SQL語句類似於:SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id
http://document.thinkphp.cn/manual_3_2.html#alias
那類似於這種原生的sql
select count(*) from (select * from user where userId >10) as a; 把一個查詢結果集起別名為a ,再count計數a
這樣的操作thinkPHP應該怎麼寫?
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.