As you can already see in the title I want to connect to a PostgreSQL Database I created on a server using PHP and Yii2. Unfortunately I am a total novice when it comes to this kind of job and I have never done it before so I have several questions that I hope some of you can answer.
db.php
file containing the following code: return [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=my1DB',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
];
Is the code actually OK? Instead of localhost I will be using the host IP of course. The db my1DB
is actually created and already contains a relation named countries
.
db.php
file need to be on the server? Or is it OK if it is simply installed on my client?db.php 需要在运行 PHP 的服务器端,以防 PostgreSQL 服务器运行在 PHP 所在的同一台服务器上,您可以将其保留为 localhost,它应该可以正常工作,只需确保凭据和数据库名称存在。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.