pahanini / yii2-refiner

Yii2 search refiner (facet search)
8 stars 6 forks source link

Mysql Error - SQLSTATE[42000] #1

Open pctin opened 8 years ago

pctin commented 8 years ago

I integrated this extension to my project as following code: `public function init() { $parentRet = parent::init();

    $this->refinerSet = new \pahanini\refiner\Set([
        'refiners' => [
            // standard range
            'price' => [
                'class' => '\pahanini\refiner\db\Range',
            ],
            'teacher_id' => [
                'class' => '\pahanini\refiner\db\Count',
            ]
        ]
    ]);

    return $parentRet;
}`

in other action: `$query = FECourse::find()->where(['status' => FECourse::STATUS_ACTIVE]);

    $refinerResult = $this->refinerSet->applyTo($query);

    $refiners = $this->refinerSet->getRefinerValues();
    var_dump($refiners);die;`

but get error: _SQLSTATE[42000]: Syntax 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 use near 'all FROM courses WHERE (status=1) AND (teacher_id IS NOT NULL) GROUP BY teac' at line 1 The SQL being executed was: SELECT teacher_id as _id, COUNT(*) as all FROM courses WHERE (status=1) AND (teacher_id IS NOT NULL) GROUP BY teacherid

The problem is from Mysql with: 'as all', you need to change it to 'as all'

Can you update the lib for this?

pahanini commented 8 years ago

It's not quite clear what do you want to change, can you create PR?