Maison  >  Questions et réponses  >  le corps du texte

La requête Laravel échoue mais le même code fonctionne dans PhpMyadmin

<p>Voici le code de mon application Laravel : </p> <pre class="brush:php;toolbar:false;">fonction publique sendNotifications() { $matchingSubscriptions = DB::table('tournament_match_plan') ->join('push_subscriptions', 'push_subscriptions.age_group', '=', 'tournament_match_plan.league') ->où('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') ->obtenir(); dd($matchingSubscriptions); }</pré> <p>Voici le résultat du débogage :</p> <pre class="brush:php;toolbar:false;">IlluminateSupportCollection {#751 ▼ // appHttpControllersGuestsGuestsPushController.php:97 #articles: [] #escapeWhenCastingToString : faux }</pré> <p>Pourquoi mon code Laravel ne donne-t-il aucun résultat ? </p> <p>J'ai essayé la même requête dans PhpMyAdmin : </p> <pre class="brush:php;toolbar:false;">SELECT * DE tournoi_match_plan REJOIGNEZ push_subscriptions SUR push_subscriptions.age_group = tournoi_match_plan.league OÙ tournoi_match_plan.start = '11:20:00' ET (tournament_match_plan.team_1 = push_subscriptions.club OU tournoi_match_plan.team_2 = push_subscriptions.club);</pre> <p>En utilisant cette requête, j'ai obtenu un résultat et il était correct. </p>
P粉111627787P粉111627787431 Il y a quelques jours423

répondre à tous(1)je répondrai

  • P粉198749929

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

    Vous trouverez ci-dessous le code de travail.

    $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();

    répondre
    0
  • Annulerrépondre