我一直在构建一个磁性插件,这个类函数似乎有问题。不完全确定为什么以下函数导致站点进入服务器错误500 ??
现在这个类包含在config.xml中。它设置为当您单击save config时调用函数....这个功能工作正常,但是当我在整个网页下面包含其他两个功能时,单击保存配置时会进入错误页面。任何想法!!
<?php
class Envato_CustomConfig_Model_Observer
{
public function adminSystemConfigChangedSection()
{
$tablename_c = Mage::getStoreConfig('customconfig_options/section_one/custom_field_one');
$email = Mage::getStoreConfig('customconfig_options/section_two/custom_field_two');
$days = Mage::getStoreConfig('customconfig_options/section_two/custom_field_three');
$bind = array(
'id' => ' ',
'tablename_c' => $tablename_c,
'email' => $email,
'days' => $days,
'timeStamp' => now(),
);
//Open Database Conenction
$write = Mage::getSingleton("core/resource")->getConnection("core_write");
$query = "
insert into Envato_CustomConfig_Job (Job_Id, tablename_colummname, email_template, days, timeStamp)
values (:id, :tablename_c, :email, :days, :timeStamp);
";
$write->query($query, $bind);
$res = "
SELECT Job_Id, tablename_colummname, email_template, days FROM Envato_CustomConfig_Job
WHERE tablename_colummname = :tablename_c
AND email_template = :email
AND days = :days
AND timeStamp =:timeStamp
AND Job_Id != :id
LIMIT 1;
";
$result = $write->query($res, $bind);
return Envato_CustomConfig_Model_Observer::runningJobs($result);
}
当下面的两个功能在课堂上时,整个页面都会崩溃。
public function toDateFormat($time,$format)
{
$dateAndTime = $time;
if($format == 1)
{
$dateAndTime = date('M d, Y', $dateAndTime);
return $dateAndTime;
}elseif($format == 2)
{
$dateAndTime = strtotime($time);
$dateAndTime = date('M d, Y', $dateAndTime);
return $dateAndTime;
}else
{
$dateAndTime = strtotime($time);
return $dateAndTime;
}
}
public function runningJobs($res)
{
$result = $res;
foreach($result as $record) {
$Job_Id = $record['Job_Id'];
$tablename_colummname = $record['tablename_colummname'];
$days = $record['days'];
$email_template = $record['email_template'];
$email_Details[] = explode(".",$tablename_colummname);
$count = count($email_Details);
if($count < 2)
{
$email_Details['2'] = time();
$email_Details['2'] = Envato_CustomConfig_Helper_Data::toDateFormat($email_Details['2'],1);
}
}
$bind = array(
'Job_Id' => $Job_Id,
'tableName' => $email_Details['0'],
'email' => $email_Details['1'],
'email_template' => $email_template,
'days' => $days,
'timeStamp' => $email_Details['2'],
);
//Open Database Conenction
$write = Mage::getSingleton("core/resource")->getConnection("core_write");
$query = "
insert into Envato_CustomConfig_Job (Job_Id, tableName, email, email_template, days, timeStamp)
values (:Job_Id, :tableName, :email, :email_template, :days, :timeStamp);
";
$write->query($query, $bind);
return $bind;
}
}
?>
编辑::我添加了我的XML配置只是错误在这里?
<?xml version = "1.0"?>
<config>
<modules>
<Envato_CustomConfig>
<version>0.0.1</version>
</Envato_CustomConfig>
</modules>
<global>
<events>
<admin_system_config_changed_section_customconfig_options>
<observers>
<customconfig>
<type>singleton</type>
<class>customconfig/observer</class>
<method>adminSystemConfigChangedSection</method>
</customconfig>
</observers>
</admin_system_config_changed_section_customconfig_options>
</events>
<helpers>
<customconfig>
<class>Envato_CustomConfig_Helper</class>
</customconfig>
</helpers>
<models>
<customconfig>
<class>Envato_CustomConfig_Model</class>
</customconfig>
</models>
<resources>
<customconfig_setup>
<setup>
<module>Envato_CustomConfig</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customconfig_setup>
<customconfig_write>
<connection>
<use>core_write</use>
</connection>
</customconfig_write>
<customconfig_read>
<connection>
<use>core_read</use>
</connection>
</customconfig_read>
</resources>
</global>
<adminhtml>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<customconfig_options>
<title>Email Configuration Section</title>
</customconfig_options>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
答案 0 :(得分:0)
缺少分号
$email_template = $record['email_template']
在这里
$email_Details['2'] = Envato_CustomConfig_Helper_Data::toDateFormat($email_Details['2'],1)
错误
$email_Details['2'] = strtotime(now());
使用更好的IDE;)
答案 1 :(得分:0)
如果您收到错误500,那么您首先要检查的是日志。 看看/ var / log,你可能会有错误(我猜system.log但是看看最近的错误)。
然后,如果你给我们带来信息,我们将能够帮助你,但你甚至可能自己解决它! :)