我正在使用以下更新查询,
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$query = UPDATE `catalog_product_entity_decimal` val SET val.value = '11'
WHERE val.attribute_id = 75 AND
val.entity_id = (select cv.entity_id from `catalog_product_entity` as cv where cv.sku = '25' limit 1)
$afected = $db->query($query);
如何从上述查询中获取受影响的行数?。我已经看过了 https://magento.stackexchange.com/questions/10623/how-do-i-get-the-mysql-affected-rows-using-the-magento-resource - 但那些对我不起作用。
请就上述问题向我提出建议。
最佳答案
您需要使用 $db->exec($query);
而不是 $db->query($query);
。它返回受影响的行数。
关于mysql - 如何使用 Magento 资源获取受 MySQL 影响的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20756029/