我正在努力寻找处理餐厅营业时间的最佳方法。复杂性是由于以下事实:
因此,一个好的方法似乎是记录一周中每一天的开放/关闭时间数组,格式为:seconds since the beginning of the week。这是一个例子
{
"address": "street 1, city, postcode",
"hours" : {
"mon" : [
{
"opened" : 25200, // 07:00
"closed" : 52200 // 14:30
}
],
"tue" : [
{
"opened" : 111600, // 07:00
"closed" : 138600 // 14:30
},
{
"opened" : 153000, // 18:30
"closed" : 180000 // 02:00 (of the day after)
}
],
...
}
}
Run Code Online (Sandbox Code Playgroud)
(在模型中,我有一个静态变量,它使用我编写的一小段代码来渲染每个字段的自动表单下拉列表)
在我看来,整周的开放时间是这样的:
Monday: {{#each hours.mon}} …Run Code Online (Sandbox Code Playgroud) 我们正在使用zend_db_table,因为Zend Framework抱怨两个事务处于活动状态,所以我们遇到了一些问题:
[message:protected] => There is already an active transaction
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/vhosts/test.local/private/library/Zend/Db/Adapter/Pdo/Abstract.php
[line:protected] => 305
[trace:Exception:private] => Array
Run Code Online (Sandbox Code Playgroud)
这是Controller中的代码:
public function convertAction()
{
$this->setNoRender();
// If the quote is a copy of a previous one, fetch all the datas
$quoteId = Zend_Filter::filterStatic($this->getRequest()->getParam('qte_id'), 'int');
$quoteTable = new Model_QuotesTable();
$quoteRow = $quoteTable->findById($quoteId);
if (count($quoteRow)) {
$clonedId = $quoteRow->convertToJob();
$this->flashMessageRedirect('Quotation successfully converted', '/jobs/edit/job_id/' . $clonedId);
} else {
$this->flashMessageRedirect('Unable to find the quote to be converted', '/quotes'); …Run Code Online (Sandbox Code Playgroud)