如何使用集合截断magento表
我有一张定制的桌子。 我想在不使用SQL查询的情况下使用Magento集合截断表如何使用集合截断magento表,magento,magento-1.7,Magento,Magento 1.7,我有一张定制的桌子。 我想在不使用SQL查询的情况下使用Magento集合截断表 希望有人能提供一些有用的信息以下是cron/schedule表的一个小示例: require_once('./app/Mage.php'); Mage::app("default"); /** @var Mage_Cron_Model_Resource_Schedule $cron */ $cron = Mage::getResourceModel('cron/schedule'); $cron->ge
希望有人能提供一些有用的信息以下是cron/schedule表的一个小示例:
require_once('./app/Mage.php');
Mage::app("default");
/** @var Mage_Cron_Model_Resource_Schedule $cron */
$cron = Mage::getResourceModel('cron/schedule');
$cron->getReadConnection()->delete(
$cron->getMainTable(),
'1=1'
);
如果您在模块中扩展了Mage_Core_Model_Resource_Db_Abstract,则此示例将起作用,您应该使用getWriteConnection而不是getReadConnection。我知道有点晚了,但:
$tableName = $collection->getResource()->getMainTable();
$conn = $collection->getConnection();
$conn->truncateTable($tableName);
它将删除所有记录。正如我所知,没有sql查询,无法运行truncate命令。