0

This sql segment works fine but meqp validator reports the possible raw sql error 'select `review_id

foreach ($post['cons'] as $key => $value) {
            $array[] = $key;
        }
$inCond = $this->getConnection()->prepareSqlCondition('cons_id', ['in' => $array]);
$sql = 'select `review_id` from (select `review_id`, count(*) as total 
        from '.$this->getTable('bss_review_pros_cons').'
        where '. $inCond .'
        group by `review_id`) as bb  where total = ' .count($array);

 $reviewIds = $this->getConnection()->fetchCol($sql);

it will return a review_id array. ex: [215,314].

  • SELECT review_id, COUNT(*) as total from '.$this->getTable('bss_review_pros_cons').' where '. $inCond .' group by review_id) as bb where total = ' .count($array); – Aditya Shah Dec 25 '18 at 17:38
  • I have received an error Possible raw SQL statement 'select review_id from (select review_id, count(*) as total detected. when i validate by meqp. – Thành Trung Tô Dec 26 '18 at 2:59
  • I hope you have created bss_review_pros_cons table resource model & collection factory in magento's way. Now you have to call your collectionFactory class & use getAllIds function to the collectionObject – Himanshu Dec 26 '18 at 4:44
  • i have created bss_review_pros_cons table in resource model.But I don't know how to sort out the array that I need. – Thành Trung Tô Dec 26 '18 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.