Jump to content
thirty bees forum

Question

Posted

So I have an old module, that is using oldscool sql calls. How would I replace... mysqliquery mysqlifetchassoc mysqlinumrows like... ``` $GLOBALS['___mysqlist'] = mysqliconnect(DBSERVER, DBUSER_, DBPASSWD_);

$sql2 = mysqliquery($GLOBALS['___mysqlist'], ' SELECT * FROM '._DB_PREFIX_.'product_shop WHERE id_product = '.(int)$idc['idproduct'].' AND id_shop = '.(int)$this->context->shop->id.' '); $result2 = mysqlifetchassoc($sql2); $count2 = mysqlinum_rows($sql2); ```

4 answers to this question

Recommended Posts

  • 0
Posted

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( (new DbQuery()) ->select('*') ->from('product_shop', 'ps') ->where('ps.`id_product` = '.(int) $idc['id_product']) ->where('ps.`id_shop` = '.(int) $this->context->shop->id) );

  • 0
Posted

I thought.. $result2 = mysqlifetchassoc($sql2); $count2 = mysqlinumrows($sql2);

would be.. $result2 = Db::getInstance(PSUSESQLSLAVE_)->getRow($sql2); count2 = Db::getInstance()->numRows();

but I'm confused on how to change sql2 to a newer style. tb1.0.2 type style....

  • 0
Posted

getRow will return only single row (the first one). executeS will return array of all matching rows. To get the count, you can just count the result (count($result))

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...