mardi 29 mai 2018

laravel DB laravel 5

        $period = DB::select("
SET @SQL = NULL;
SELECT
  GROUP_CONCAT(DISTINCT
    CONCAT(
      'sum(case when date_time_r = ''',
      date_time_r,
      ''' then count_pursh else 0 end) AS `',
      date_time_r, '`'
    )
  ) INTO @SQL
FROM
(
select Date_format(vuuuee.date_time, '%Y-%M') as date_time_r from vuuuee
where 
 date(vuuuee.date_time) <= date '2018-05-15' 
 and date(vuuuee.date_time) >= date '2017-04-11' 
group by vuuuee.date_time
) d;

SET @SQL 
  = CONCAT('SELECT `id`, ', @SQL, ' 

FROM
(
select id, count_pursh, Date_format(vuuuee.date_time, \'%Y-%M\') as date_time_r from vuuuee
where 
 date(vuuuee.date_time) <= date \'2018-05-15\' 
 and date(vuuuee.date_time) >= date \'2017-04-11\' 
group by vuuuee.id, vuuuee.date_time
) r    
                group by id
                ');

PREPARE stmt FROM @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;");

How correctly request in laravel 5? Now I get an error but in HeidiSQL it works dsSyntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to us



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2L1FbA6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire