0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

cakePHP データベース接続設定

Last updated at Posted at 2021-07-13

Every Qiita #11
のんびり独学初学者の毎日投稿チャレンジ 11日目
今回は・・・
前回記事でご教示頂いたソートに関しての備忘録です。

app.phpファイルで設定

app.php
'Datasources' => [
       'default' => [
           'className' => 'Cake\Database\Connection',
           'driver' => 'Cake\Database\Driver\Mysql',
           'persistent' => false,
           'host' => 'localhost',
           'username' => env('DB_USERNAME',false),
           'password' => env('DB_PASSWORD',false),
           'database' => env('DB_DATABASE',false),
           'encoding' => 'utf8',
           'timezone' => 'UTC',
           'cacheMetadata' => true,

ブラウザで確認してみます。

スクリーンショット 2021-07-13 12.12.26.png

エラーが出ています・・・

原因

app_local.phpにapp.phpと同じ記述があった場合、上書きされるみたいです。
環境変数の設定等で問題あるかと思っていたので、解決するまでに時間がかかりました・・・初歩的なミスでした:cry:

app_local.phpに書き込み、サーバーを再起動して確認

スクリーンショット 2021-07-13 12.11.10.png

無事接続できました!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?