thinkphp5master方法讀取主庫

thinkphp5 master方法讀取主庫

創(chuàng)新互聯(lián)是一家專業(yè)提供建水企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、H5技術(shù)、小程序制作等業(yè)務(wù)。10年已為建水眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。

thinkphp5 master方法讀取主庫

默認(rèn)是主庫寫,從庫讀。

   'rw_separate' => true,

在讀寫分離的情況下,默認(rèn)第一個(gè)數(shù)據(jù)庫配置是主服務(wù)器的配置信息,負(fù)責(zé)寫入數(shù)據(jù),如果設(shè)置了master_num參數(shù),則可以支持多個(gè)主服務(wù)器寫入。其它的都是從數(shù)據(jù)庫的配置信息,負(fù)責(zé)讀取數(shù)據(jù),數(shù)量不限制。每次連接從服務(wù)器并且進(jìn)行讀取操作的時(shí)候,系統(tǒng)會(huì)隨機(jī)進(jìn)行在從服務(wù)器中選擇。

    //讀主庫
    public function isrepeat($aid,$bid,$userid){
        if( intval($aid)<1 || intval($bid)<1 || intval($userid)<1 ){return false;}
        $count=Db::table('student')->master()->where("`aid`=$actid and `bid`=$bid and `userid`=$userid")->count();
        return $count;
    }

180605筆記  今天周五,大太陽,熱,充實(shí)的下午,明天端午節(jié),碼農(nóng)們,放假咯

The end

網(wǎng)站欄目:thinkphp5master方法讀取主庫
網(wǎng)站地址:http://bm7419.com/article6/psscog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站網(wǎng)頁設(shè)計(jì)公司外貿(mào)網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、商城網(wǎng)站、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化