我遵循了本书中提到的相同步骤,关键步骤是:
在<Module Directory>/etc/config.xml
创建资源设置配置,如下所示:
<?xml version="1.0"?>
<config>
<global>
<modules>
<Foggyline_HappyHour>
<version>1.0.0.0</version>
</Foggyline_HappyHour>
</modules>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<model>Foggyline_HappyHour</model>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
使用以下脚本在<Module Directory>/sql/foggyline_happyhour_setup/install-1.0.0.0.php
创建迁移脚本:
<?php
// Just checking if the script is executed
echo 'Thank you for your help :)';
加载任何页面并检查页面是否打印消息。
不,它没有打印任何东西。该脚本根本没有运行。
我们如何解决这个问题?
答案 0 :(得分:0)
:(显然书中有错误):
根据official docs,设置定义应为<module>
,而不是<model>
。因此:
<?xml version="1.0"?>
<config>
<global>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<module>Foggyline_HappyHour</module>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
现在我可以看到脚本已执行。 :)