Die Laravel-Abfrage schlägt fehl, aber der gleiche Code funktioniert in PhpMyadmin
P粉111627787
P粉111627787 2023-08-15 17:54:08
0
1
424
<p>Dies ist der Code für meine Laravel-Anwendung: </p> <pre class="brush:php;toolbar:false;">öffentliche Funktion sendNotifications() { $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('tournament_match_plan.team_1', '=', 'push_subscriptions.club') ->orwhere('tournament_match_plan.team_2', '=', 'push_subscriptions.club') ->get(); dd($matchingSubscriptions); }</pre> <p>Dies ist das Debugging-Ergebnis:</p> <pre class="brush:php;toolbar:false;">IlluminateSupportCollection {#751 ▼ // appHttpControllersGuestsGuestsPushController.php:97 #Artikel: [] #escapeWhenCastingToString: false }</pre> <p>Warum liefert mein Laravel-Code keine Ergebnisse? </p> <p>Ich habe die gleiche Abfrage in PhpMyAdmin versucht: </p> <pre class="brush:php;toolbar:false;">SELECT * VON Tournament_match_plan Treten Sie push_subscriptions bei push_subscriptions.age_group = Tournament_match_plan.league bei WO Tournament_match_plan.start = '11:20:00' UND (tournament_match_plan.team_1 = push_subscriptions.club ODER Tournament_match_plan.team_2 = push_subscriptions.club);</pre> <p>Mit dieser Abfrage habe ich ein Ergebnis erhalten, und es war korrekt. </p>
P粉111627787
P粉111627787

Antworte allen(1)
P粉198749929

以下是工作代码。

$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();
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!