我发现了一些与此问题相关的其他帖子,但是我无法实现我想要的,所以我决定删除所有内容并从一些帮助开始...
到目前为止,这是我的工作,它完成了工作,但数据是在数组中硬编码的,我需要创建一个数据库连接来获取这些数据.
在我的模块类中,我有:
public function getViewHelperConfig()
{
return array(
'factories' => array(
'liveStreaming' => function() {
return new LiveStreaming();
},
),
);
}
Run Code Online (Sandbox Code Playgroud)
这是我在视图助手中的代码:
namespace Application\View\Helper;
use Zend\View\Helper\AbstractHelper;
class LiveStreaming extends AbstractHelper
{
protected $liveStreamingTable;
public function __invoke()
{
$events = array(
'1' => array('name' => 'Event name',
'sport' => 'Soccer',
'time' => '11:30'),
'2' => array('name' => 'Event name',
'sport' => 'Soccer',
'time' => '17:00'),
);
return $events;
//this is what should be used (or something like that) to …Run Code Online (Sandbox Code Playgroud)