Rumah  >  Soal Jawab  >  teks badan

Pertanyaan Laravel gagal tetapi kod yang sama berfungsi dalam PhpMyadmin

<p>Ini ialah kod untuk aplikasi Laravel saya: </p> <pre class="brush:php;toolbar:false;">public function sendNotifications() { $matchingSubscriptions = DB::table('tournament_match_plan') ->sertai('push_subscriptions', 'push_subscriptions.age_group', '=', 'tournament_match_plan.league') ->di mana('pelan_perlawanan_perlawanan.mula', '=', '11:20:00') ->di mana('plan_perlawanan_kejohanan.team_1', '=', 'push_subscriptions.club') ->orwhere('tournament_match_plan.team_2', '=', 'push_subscriptions.club') ->dapatkan(); dd($matchingSubscriptions); }</pre> <p>Ini ialah hasil penyahpepijatan:</p> <pre class="brush:php;toolbar:false;">IlluminateSupportCollection {#751 ▼ // appHttpControllersGuestsGuestsPushController.php:97 #item: [] #escapeWhenCastingToString: palsu }</pre> <p>Mengapa kod Laravel saya tidak mendapat hasil? </p> <p>Saya mencuba pertanyaan yang sama dalam PhpMyAdmin: </p> <pre class="brush:php;toolbar:false;">SELECT * DARI tournament_match_plan SERTAI push_subscriptions DI push_subscriptions.age_group = tournament_match_plan.league WHERE tournament_match_plan.start = '11:20:00' DAN (rancangan_perlawanan_kejohanan.team_1 = push_subscriptions.club ATAU tournament_match_plan.team_2 = push_subscriptions.club);</pre> <p>Menggunakan pertanyaan ini saya mendapat keputusan, dan ia adalah betul. </p>
P粉111627787P粉111627787431 hari yang lalu426

membalas semua(1)saya akan balas

  • P粉198749929

    P粉1987499292023-08-16 09:07:16

    Di bawah ialah kod kerja.

    $matchingSubscriptions = DB::table('tournament_match_plan')
            ->join('push_subscriptions', 'push_subscriptions.age_group', '=', 'tournament_match_plan.league')
            ->where('tournament_match_plan.start', '=', '11:20:00')
            ->where(function ($query) {
                $query->where('tournament_match_plan.team_1', '=', DB::raw('push_subscriptions.club'))
                    ->orWhere('tournament_match_plan.team_2', '=', DB::raw('push_subscriptions.club'));
            })
            ->get();

    balas
    0
  • Batalbalas