ページの作成

ページの作成

親となるページを選択してください。

ページは必ず何かしらの親ページに紐づきます。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球

子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール

親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
テンプレートを更新

3. 複数のデータベースに接続する方法

本稿ではLaravelにて複数データベースに接続する方法に関して記述します。

 

ポイントは「/config/database.php」ファイルとなるので開きましょう。

もうひとつDBの設定を追加する場合は以下のように記述します。(黄色い文字が追記した部分)

    'default' => env('DB_CONNECTION', 'mysql'),

    'connections' => [

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

      'mysql2' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST_2', '127.0.0.1'),
            'port' => env('DB_PORT_2', '3306'),
            'database' => env('DB_DATABASE_2', 'forge'),
            'username' => env('DB_USERNAME_2', 'forge'),
            'password' => env('DB_PASSWORD_2', ''),
            'unix_socket' => env('DB_SOCKET_2', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],   

],

 

.envファイルには「DB_HOST_2」など新しいDBの接続設定を記述しておいて下さい。

実際に2つ目のSQLを実行する際には以下のように記述します。

DB::connection('mysql2')->select('select * from members');

 

なお、1つめのDBに接続する際は今までどおり明示的な「connection」を記述する必要はありません。

理由は「/config/database.php」の「default」に設定されているのが1つめのDBだからです。

以下、もう少し複雑なSQLの実行例。

$results = DB::connection('mysql2')
                ->table('ret_t_tweet')
                ->join('ret_m_user', 'ret_t_tweet.user_id', '=', 'ret_m_user.id')
                ->where('ret_m_user.delete_flag', 0)
                ->where('ret_t_tweet.created_at_shaped', ">=", $today)
                ->select('ret_t_tweet.tweet_url as tweet_url'
                        , 'ret_t_tweet.text as text'
                        , 'ret_t_tweet.created_at_shaped as created_at_shaped'
                        , 'ret_m_user.id as user_id'
                        , 'ret_m_user.name as user_name'
                        )
                ->paginate(10);

 

モデル (Eloquent) に設定する場合。

class Sample extends Model
{

    protected $connection = 'mysql2';

}

 

子ページ
子ページはありません
同階層のページ
  1. config/database.phpファイル
  2. .env
  3. 複数のデータベースに接続する方法
  4. DBトランザクション
  5. DBの悲観ロック

最近の質問

コメント一覧

    No.96 | guest | 2022-09-21 08:49:27

    bunadisisj nsjjsjsisjsmizjzjjzjzz zumzsert

    No.95 | guest | 2022-09-02 14:27:36

    bunadisisj nsjjsjsisjsmizjzjjzjzz zumzsert

    No.94 | guest | 2022-06-25 20:26:24

    slot cleopatra penny [url="https://www-slotmachines.com"]casino world slots[/url] slot machines free games

    No.93 | guest | 2022-06-25 01:15:32

    quick hit slots free [url="https://slotmachinesworld.com"]hawk play casino[/url] free slots vegas world games

    No.92 | guest | 2022-06-24 05:04:34

    free unique casino [url="https://slotmachinesforum.net"]free game online slot[/url] 777lukislot

    No.91 | guest | 2022-06-23 08:52:57

    porn slots [url="https://slotmachinescasinos.com"]alicasino[/url] konami slots for computer

    No.90 | guest | 2022-06-22 13:45:16

    slots free single [url="https://slotmachinescafe.com"]best slots online[/url] free quick hit slots

    No.89 | guest | 2022-06-21 16:44:41

    free konami slots online [url="https://slotmachineonlinegratis.org"]free slots no download[/url] free konami slots online

    No.88 | guest | 2022-06-20 20:45:43

    lucky slots 777 free play [url="https://slotmachinegameinfo.com"]vegas world slots online[/url] free mobile bets

    No.87 | guest | 2022-06-20 00:17:10

    play downtown vegas on facebook [url="https://slotmachinegambler.com"]free slots to play for fun[/url] play slots online free

    No.86 | guest | 2022-06-19 02:21:22

    youtube slots [url="https://pennyslotmachines.org"]free slots play[/url] casino slots free

    No.85 | guest | 2022-06-18 05:19:24

    jackpotjoy [url="https://giocoslotmachinegratis.com"]casino slot machines[/url] fun game slot

    No.84 | guest | 2022-06-17 08:14:24

    super high limit slots [url="https://freeonlneslotmachine.com"]online slots that pay real money[/url] guide casinos

    No.83 | guest | 2022-06-16 12:33:34

    lucky plus 777 [url="https://download-slot-machines.com"]lincoln slots online[/url] brian christopher slots on youtube

    No.82 | guest | 2022-06-15 05:47:13

    las vegas casino slots [url="https://candylandslotmachine.com"]7 free online slots machines[/url] casino with slots near me

    No.81 | guest | 2022-06-14 09:28:08

    paymygame [url="https://beat-slot-machines.com"]100% free slots games[/url] igt slots free

    No.80 | guest | 2022-06-13 13:14:06

    murka slots girls [url="https://411slotmachine.com"]skill machine app[/url] free slots vegas

    No.79 | guest | 2022-06-13 06:25:36

    複数のデータベースに接続する方法 < データベースの設定 < Laravel < フレームワーク < PHP < プログラミング言語 - IT技術総合Wiki | CWiki <a href="http://www.g8v0t5jew588hz1x1li925d7r1i2q95rs.org/">atzyghlezvz</a> tzyghlezvz http://www.g8v0t5jew588hz1x1li925d7r1i2q95rs.org/ [url=http://www.g8v0t5jew588hz1x1li925d7r1i2q95rs.org/]utzyghlezvz[/url]

    No.78 | guest | 2022-06-12 16:56:19

    instanslot [url="https://2-free-slots.com"]free slots from vegas[/url] old vegas slots

    No.77 | guest | 2022-06-09 11:05:07

    youtube slots casino [url="https://411slotmachine.com"]free slots home 12345[/url] ff tactics 24 slots

    No.76 | guest | 2022-06-07 14:03:43

    calendar with time slots [url="https://2-free-slots.com"]jackpot party casino slots[/url] free slots vegas world

    No.75 | guest | 2022-05-22 10:30:58

    dissertation statistics help [url="https://mydissertationwritinghelp.com"]uchicago dissertation office[/url] dissertation crossword clue

    No.74 | guest | 2022-05-20 02:40:18

    cheap dissertation help in houston [url="https://help-with-dissertations.com"]phd dissertation example[/url] dissertation phd

    No.73 | guest | 2022-05-16 14:00:24

    business dissertation writing [url="https://helpon-doctoral-dissertations.net"]dissertation paper help[/url] dissertation editor

    No.72 | guest | 2022-05-15 15:01:02

    dissertation editor near me [url="https://dissertationwriting-service.com"]dissertation help service[/url] online dissertation help gottingen

    No.71 | guest | 2022-05-14 19:59:44

    dissertation writing service chicago il [url="https://dissertations-writing.org"]doctorate degree without dissertation[/url] dissertation case study

    No.70 | guest | 2022-03-27 10:31:12

    And while, french massage and not violates practically any prohibitions, for the reason it&apos;s not about sexual contact. Dear gentlemen! Systematically visiting the four hands massage for clients, you guarantee himself excellent sexual relaxation. In school sensual massage women will hold erotic 4hands massage. Similar swedish massage, as in principle, and relaxation, influences on some area human body, this give a chance male gain strength. Sensitive touch rasprekrasnoy girls will flow through your body, dipping in depth boundless the ocean pleasure. In the quiet slip, donating your skin kisses, prelestress envelops the warmth of one&apos;s body. You will be surprised at, which sea bliss today it is possible to feel fromnude massage in Midtown. [url=https://massagenyc.mystrikingly.com/]Качественный контент 10 вдохновляющих и 13 действенных[/url]

    No.69 | guest | 2022-02-19 06:17:23

    how to put a quote in an essay [url="https://yoursuperessay.com/"]essay spanish slang[/url] how to write an essay for college admission

    No.68 | guest | 2022-02-18 06:54:00

    what is the best vpn service [url="https://windowsvpns.com/"]hma pro vpn[/url] how to get a vpn

    No.67 | guest | 2022-02-17 07:35:52

    best vpn for xbox one [url="https://vpnsrank.com/"]vpn meaning[/url] buy vpn cheap

    No.66 | guest | 2022-02-16 07:26:16

    best vpn trial [url="https://vpnshroud.com/"]best vpn torrenting[/url] cheap vpn

    No.65 | guest | 2022-02-15 09:37:10

    unlimited free vpn [url="https://vpn4torrents.com/"]vpn free google chrome[/url] buy vpn online

    No.64 | guest | 2022-02-14 11:32:15

    critical thinking problem solving [url="https://uncriticalthinking.com/"]lab aseptic technique critical thinking #4[/url] critical thinking activities for middle school

    No.63 | guest | 2022-02-13 12:32:35

    browser vpn free [url="https://topvpndeals.net/"]business class vpn[/url] buy cyberghost vpn

    No.62 | guest | 2022-02-12 13:03:25

    spongebob essay meme [url="https://topessayswriter.com/"]essay typer com[/url] why nyu essay examples

    No.61 | guest | 2022-02-11 14:35:06

    vpn free download windows 10 [url="https://tjvpn.net/"]free internet vpn[/url] which vpn is best

    No.60 | guest | 2022-02-10 15:49:00

    best vpn for pc [url="https://thebestvpnpro.com/"]hola vpn[/url] best buy vpn router

    No.59 | guest | 2022-02-09 16:36:32

    gay mucle dating [url="https://speedgaydate.com/"]gay nmale dating sites in southern california[/url] gay muscle dating

    No.58 | guest | 2022-02-08 22:03:26

    online casino no deposit [url="https://onlinecasinohero.com/"]free online games to win real money no deposit[/url] casino bonuses online

    No.57 | guest | 2022-02-04 07:32:08

    keto diet simple [url="https://ketogenicdiets.net/"]keto diet grocery list[/url] keto vs atkins diet

    No.56 | guest | 2022-02-03 10:12:43

    cyclical keto diet [url="https://ketogenicdietinfo.com/"]keto diet vegan[/url] keto diet chart

    No.55 | guest | 2022-02-02 13:01:37

    vegan keto diet [url="https://ketogendiets.com/"]keto diet food plan[/url] cyclic keto diet

    No.54 | guest | 2022-02-01 15:01:27

    what's keto diet [url="https://ketogendiet.net/"]dangers of keto diet[/url] keto diet oatmeal

    No.53 | guest | 2022-01-31 17:42:19

    essay cover page example [url="https://howtowriteessaytips.com/"]respond essay[/url] tuskegee experiment essay

    No.52 | guest | 2022-01-30 20:38:25

    teen gay chat rooms [url="https://gaytgpost.com/"]gay skype chat room[/url] gay chat rooms ring central

    No.51 | guest | 2022-01-29 23:11:52

    chubby gay mens dating sites <a href=https://gaysugardaddydatingsites.com/>gay man, straight man dating</a> free gay dating sites grindr

    No.50 | guest | 2022-01-29 06:36:39

    dating site for gay <a href=https://gayprideusa.com/>which senior gay dating app has most members lakeland fl</a> gay dating in tupelo

    No.49 | guest | 2022-01-28 14:07:37

    does pof allow for gay dating <a href=https://gaypridee.com/>gay dating in clarksville</a> gay dating sites sanford nc

    No.48 | guest | 2022-01-27 21:31:51

    gay dating apps <a href=https://gayfade.com/>gay macho dating</a> mister gay dating app

    No.47 | guest | 2022-01-27 04:11:29

    gay chat cam <a href=https://gay-buddies.com>gay roulette chat</a> gay chat cams free

    No.46 | guest | 2022-01-26 06:01:12

    admission essay <a href=https://essaysitesreviews.com>essay outline high school</a> persuasive essay ideas

    No.45 | guest | 2022-01-25 07:32:34

    illustration essay <a href=https://essayscratch.com>descriptive essay topics</a> essay cover page example

    No.44 | guest | 2022-01-24 08:58:32

    lab aseptic technique critical thinking #4 <a href=https://criticalthinkinginstitute.com>critical thinking pictures</a> critical thinking for students

    No.43 | guest | 2022-01-23 11:07:24

    critical thinking in the classroom <a href=https://criticalthinkingbasics.com>critical thinking is the process of</a> critical and creative thinking

    No.42 | guest | 2022-01-22 12:45:07

    decision making and critical thinking <a href=https://criticalthinking2020.net>critical thinking theory</a> ati critical thinking

    No.41 | guest | 2022-01-21 14:52:56

    windows 10 vpn <a href=https://choosevpn.net>express vpn free</a> private vpn

    No.40 | guest | 2022-01-20 15:29:15

    gay chat random x4 <a href=https://bjsgaychatroom.info>best free gay chat</a> random gay webcam chat

    No.39 | guest | 2022-01-19 15:54:37

    college essay guy <a href=https://anenglishessay.com>free essay generator</a> write an argumentative essay

    No.38 | guest | 2022-01-18 19:04:44

    best vpn wirecutter <a href=https://addonsvpn.com>trustzone vpn</a> free vpn server list

    No.37 | guest | 2022-01-01 21:28:31

    apa essay example <a href=https://essaytodo.com/?>essays on writing</a> essay writing website

    No.36 | guest | 2021-12-30 18:42:24

    i hate writing essays <a href=https://dollaressays.com/?>good college essay samples</a> how to write a profile essay

    No.35 | guest | 2021-12-28 16:54:29

    my dream essay <a href=https://essayprepworkshop.com/?>compare and contrast essay</a> what to write in a college essay

    No.34 | guest | 2021-12-27 14:14:15

    writing an evaluation essay <a href=https://checkyouressay.com/?>what is an expository essay</a> typing essay in verdana

    No.33 | guest | 2021-12-23 13:03:02

    what to write about in college essay <a href=https://casinogamesmachines.com/?>analysis essay writing</a> writing college essays

    No.32 | guest | 2021-12-22 14:49:32

    write my college essay <a href=https://casinoonlinek.com/?>essays to write</a> i need help writing an essay

    No.31 | guest | 2021-12-21 14:01:36

    best custom essay writing services <a href=https://onlinecasinoad.com/?>writing analysis essay</a> write my essay for cheap

    No.30 | guest | 2021-12-20 16:56:32

    writing essays for money <a href=https://casinoonlinet.com/?>write essays online</a> help writing an essay

    No.29 | guest | 2021-12-19 18:14:20

    cheapest essay writing service <a href=https://multiessay.com/?>essays to write</a> write and essay

    No.28 | guest | 2021-12-17 21:52:38

    writes essay for you <a href=https://student-essay.com/?>write analysis essay</a> analysis essay writing

    No.27 | guest | 2021-12-16 15:20:00

    the best essay writing service <a href=https://buy1essay.com/?>writing a reflection essay</a> custom writing essay

    No.26 | guest | 2021-12-15 14:00:37

    asian sex games <a href=https://sexygamess.com/?>sex games no credit card</a> couples plays strip poker and sex games

    No.25 | guest | 2021-12-14 16:53:37

    sex games on play store <a href=https://sexgameszone.com/?>sex games video</a> pool sex games

    No.24 | guest | 2021-12-13 19:28:11

    steam for sex games <a href=https://sex4games.com/?>diy sex games</a> 3d sex games porn

    No.23 | guest | 2021-12-12 09:36:03

    brandi belle sex games <a href=https://winsexgames.com/?>adult sex games for android</a> best sex games on the internet for free

    No.22 | guest | 2021-12-11 10:44:33

    the best sex games <a href=https://sexygamess.com/?>gay sex games</a> card games nude adult sex games

    No.21 | guest | 2021-12-06 13:07:44

    keto diet list <a href=https://ketogenicdietinfo.com/?>shark tank keto diet</a> keto friendly wine

    No.20 | guest | 2021-12-05 15:23:44

    keto apple crisp <a href=https://ketogenicdietinfo.com/?>keto foods list</a> keto diet\

    No.19 | guest | 2021-12-04 13:56:00

    wwe sex games <a href=https://sexgamesx.net/?>wonder woman sex games</a> sex pc games

    No.18 | guest | 2021-11-30 07:24:01

    xxx sex games <a href=https://sex4games.com/?>sex games better than 3dsexvilla 2</a> sex games vegas the bet

    No.17 | guest | 2021-11-29 11:41:38

    interactive 3d sex games <a href=https://sex4games.com/?>3d interactive sex games</a> extreme sex games

    No.16 | guest | 2021-11-26 10:41:27

    attack on titan sex games <a href=https://sexgameszone.com/?>my free sex games</a> roblox sex games

    No.15 | guest | 2021-11-09 06:58:59

    opinion essay example <a href=https://essaytodo.com/?>how to write a comparative essay</a> write an essay introduction

    No.14 | guest | 2021-11-05 05:16:26

    help writing essays <a href=https://essaytodo.com/?>custom essays writing</a> paid to write essays

    No.13 | guest | 2021-10-15 00:44:48

    website for resume <a href=https://essaysnet.com/?>scholarship essay writing service</a>

    No.12 | guest | 2021-10-10 20:40:29

    essays for money <a href=https://essayghostwriter.com/?>fantasy writers</a>

    No.11 | guest | 2021-09-15 22:56:49

    gay dating site australia gay herpes dating <a href=http://gaydatingcanada.com/?>gay dating phone sites</a>

    No.10 | guest | 2021-09-13 01:00:03

    gay latino dating dating a guy you think is gay <a href=http://datinggayservices.com/?>gay mobile dating sites</a>

    No.9 | guest | 2021-09-08 03:09:34

    international gay dating gay-dating <a href=gayedating.com?>top 10 gay dating websites</a>

    No.8 | guest | 2021-09-06 06:18:09

    christian dating site gay dating gay cowboys <a href=http://gaychatgay.com?>gay chat dating site</a>

    No.7 | guest | 2021-09-03 04:31:20

    gay sites for dating how to delete dating sites gay <a href=http://gaychatgay.com?>fre gay dating</a>

    No.6 | guest | 2021-08-17 23:43:02

    gay dating sim for android limerick gay dating <a href=http://gaychatrooms.org?>gay poly dating</a>

    No.5 | guest | 2021-08-15 01:52:33

    gay dating pakistan best gay dating side for free <a href=http://gaychatrooms.org?>iowa gay dating site</a>

    No.4 | guest | 2021-08-12 03:40:06

    christian gay dating site online dating for gay men <a href=http://freegaychatnew.com?>black gay men dating site</a>

    No.3 | guest | 2021-08-08 00:34:25

    famous gay dating sites mature gay men dating site <a href=http://gaychatus.com?>adult gay dating</a>

    No.2 | guest | 2021-07-30 19:09:47

    dating websites new <a href=http://onlinedatingtwo.com/?>nina dobrev dating</a>

    No.1 | guest | 2021-07-29 15:40:36

    chat adult <a href=http://onlinedatinglook.com/?>free dating websites</a>