如何使用集合截断magento表

Vij*_*S91 5 magento magento-1.7

我有一个自定义表.我想在没有SQL查询的情况下使用Magento集合截断表.

希望有人能提供一些有用的信息

kli*_*ach 0

这是 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'
);
Run Code Online (Sandbox Code Playgroud)

如果您在模块中扩展 Mage_Core_Model_Resource_Db_Abstract,则此示例将起作用,并且您应该使用 getWriteConnection 而不是 getReadConnection。