search
Homephp教程php手册thinkphp 5 multiple database connection

I recently worked on a project that required connecting to multiple databases. I read the distributed database in the manual. After setting it up according to the above, I was still a little confused about what to do next. Then I guessed the next way of writing based on the manual to connect to the database and successfully add data, but I don’t know how to do it. If there are any problems with the writing, please ask the experts for guidance
    // database.php 中配置   主要修改这两项配置<br> <br>     // 数据库名  'database'    => '默认数据库的名称,第二个数据库的名称',<br>    'database'    => 'a,b',<br> <br>     // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)<br>     'deploy'      => 1,<br> <br>     详细配置参考手册<br>     http://www.kancloud.cn/manual/thinkphp5/118061<br> <br>     public function books(){<br>         $data['donor_name'] = 'haha';<br>         $data['donor_phone'] = '254658785545';<br> <br>         self::much('donor')->insert($data);<br>     }<br> <br>     //$db  第二个数据库的名称     $table  表名称<br>     protected function much($table,$db='b.'){<br>        return Db::table($db.$table);<br>     }

Yunqi Conference Beijing Station: It is rare for Alibaba technical experts to appear on the scene. This time, more than 100 people came? !

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)