A
A
Andy Developer2017-05-17 04:15:05
MySQL
Andy Developer, 2017-05-17 04:15:05

Is select working incorrectly and/or strange in Laravel's DB:select?

I created the following sql query to the database

select
        date,
                                site,
                                uin,
                                raw
                            from
                                (select 
                                    date(date) as date, 
                                    site as site,
                                    sum(uin) as uin,
                                    sum(raw) as raw
                                from 
          daily_stats
                                    WHERE 
          site = 'all' and
           month(date) = month(curdate())
                                group by site, date
                                ) as daily_sum
                                  order by date
                                  limit 1;

I execute it in Mysql Workbench, I get what I need I execute it in
a09aab81a5.jpg
laravel service
$statsRows = DB::select('select
                                date,
                                site,
                                uin,
                                raw
                            from
                                (select 
                                    date(date) as date, 
                                    site as site,
                                    sum(uin) as uin,
                                    sum(raw) as raw
                                from 
                                    daily_stats
                                WHERE 
                                  site = :site and
                                  month(date) = month(:month)
                                group by site, date
                                ) as daily_sum
                                  order by date;
                                  ',
                                    [
                                        'site' => $site,
                                        'month' => $month
                                    ]);

while everything is as it should be
ae64ca00b2.jpg
, now I change 'all' to 'domain.com', in mysql workbench I get the correct data
a89dddbaa3.jpg
and in the laravel service, nifiga is not what I need,
b3a20862d6.jpg
how can this be? :)
I don't understand anything, in both cases the input data is the same, with site = 'all' it works in both places, with site = 'domain.com' only in mysql workbench
ps I apologize for formatting the code, I can't insert it normally.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question