This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

vinay.lobo198634018
vinay.lobo198634018

Unable to pass in an array of strings (month_year) for the wherein clause, as in the code below:


    <?
    public static function monthly_aggregates($month_year)
        {
            $whatever = Db::connection('database_name');
            $query = "
            SELECT
        DATE_FORMAT(submitdate,'%Y%m') as 'month_year',
        COUNT(CASE WHEN 961936X1X11 >= 0 and 961936X1X11 <= 6 then 1 ELSE NULL END) as 'Detractors',
        COUNT(CASE WHEN 961936X1X11 >= 7 and 961936X1X11 <= 8 then 1 ELSE NULL END) as 'Passive',
        COUNT(CASE WHEN 961936X1X11 >= 9 and 961936X1X11 <= 10 then 1 ELSE NULL END) as 'Promoters'

        from lime_survey_961936
        where DATE_FORMAT(submitdate,'%Y%m') in (:month_year)

        GROUP BY month_year
            ";
            $results = $whatever->select($query, ['month_year' => $month_year]);

            return $results;
        }

        //calling via the code below:
        DatabaseCalls::monthly_aggregates(['201809','201810'])
        ?>
Error: array to string conversion error
daftspunky
daftspunky

This relates to Laravel's ORM/DB library (Eloquent). Try searching for this.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.