我有以下代码:
$recipients = Mage::getResourceModel('crm/crm_collection');
$recipients->getSelect()
->joinInner(array(
'link' => $recipients->getTable('crm/bulkMailLink'),
), "link.crm_id = e.entity_id", array(
'link_id' => 'link.id',
))
->where("link.queue_id = ? AND link.sent_at IS NULL", $queue->getId());
$recipients->addAttributeToSelect('title');
$recipients->addAttributeToSelect('first_name');
$recipients->addAttributeToSelect('chinese_name');
$recipients->addAttributeToSelect('last_name');
$recipients->addAttributeToSelect('email1');
$recipients->addAttributeToFilter('email1', array('neq'=>''));
$recipients->setPageSize(100);
$recipients->setCurPage(1);
然后我记录代码生成的选择语句:
Mage::log("DEBUG: ".((string)$recipients->getSelect()));
上面生成了一个可以在 phpmyadmin 中完美执行的工作 sql 查询并返回我期望的结果。
然后我记录 $recipients 的计数
Mage::log("Loading recipients for queue: {$recipients->count()}");
这就是代码停止的地方。实际上,它甚至不会记录消息。如果我注释掉上面的日志代码并尝试做一个
foreach ($recipients as $crm)
{
var_dump($crm);
die();
}
它不会进入 foreach。解析器将在 foreach 之前停止。
最糟糕的是不会打印任何错误消息。我被严重卡住了。
谢谢