小编cel*_*osa的帖子

Mongodb 处理营业时间以及如何查找某个地方是否营业

我正在努力寻找处理餐厅营业时间的最佳方法。复杂性是由于以下事实:

  • 场所可能在同一天内多次开放(例如7:00-14:30、18:30-22:00)
  • 有时关闭时间会超过午夜(例如19:00-2:00)
  • 并非每天都有相同的时间

因此,一个好的方法似乎是记录一周中每一天的开放/关闭时间数组,格式为: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)

mongodb

5
推荐指数
1
解决办法
2112
查看次数

Zend框架抱怨"已经有一个活跃的交易"

我们正在使用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)

mysql zend-framework transactions zend-db

2
推荐指数
1
解决办法
5662
查看次数

标签 统计

mongodb ×1

mysql ×1

transactions ×1

zend-db ×1

zend-framework ×1