Magento 2. Custom module.
I have to run some raw SQLs. It works and doesn't show any error. But when I'm trying to upload module to Magento 2 Market Place (developer.magento.com/extension) it shows in technical report a dozen of such errors:
Possible raw SQL statement 'UPDATE `' detected. Possible raw SQL statement 'SELECT MAX(entity_id) AS MaxOrderId FROM ' detected. Possible raw SQL statement 'SELECT COUNT(entity_id) AS CountNewOrder FROM ' detected.
What is the correct way to run this statement?
$sql = 'SELECT COUNT(entity_id) AS CountNewOrder FROM ' . $this->getDbPrefix() . 'sales_order WHERE entity_id > ' . $order_id;
$result = \Magento\Framework\App\ObjectManager::getInstance()->getConnection()->fetchAll($sql);*