prestashop_newuser Posted January 20, 2014 Share Posted January 20, 2014 Hi, I have a custom query in my module. The query is something like $sql = "SELECT * FROM "._DB_PREFIX_."product_lang WHERE `name` like '".$_GET['name']."%'"; $rows = Db::getInstance()->executeS($sql); foreach ( $rows as $row ){ $productName = $row['name']; echo '<li class="product-details">'.$productName.'</li>'; } Here its working absolutely fine. But lets say there is no results found (MySQL return result if 0 rows returned) then I want to show one message like 'sorry ne results found'.For that I need to run if(mysql_num_rows($rows) > 0) { } But how to run mysql_num_rows in prestashop according to DB Class? Can some one kindly tell me how to run this query using db class? Any help will be really appreciable. Thanks. Link to comment Share on other sites More sharing options...
prestashopninja Posted January 20, 2014 Share Posted January 20, 2014 Hi, You have DB::NumRows() method, yet the docs recommend to use SELECT COUNT(*) instead, to retrieve the number of results returned. I hope this helps. Link to comment Share on other sites More sharing options...
Recommended Posts