避免ORM返回蛋糕\的I18n \时刻
我有我的分贝以下数据避免ORM返回蛋糕的I18n 时刻
DATE DATE TIME
+--------------+------------+----------------+
| initial_date | final_date | expected_hours |
+--------------+------------+----------------+
| 2015-04-20 | 2015-05-24 | 13:00:00 |
| 2015-04-13 | 2015-05-17 | 13:00:00 |
+--------------+------------+----------------+
但是当我打电话
$this->set('weeks', $this->paginate($this->Weeks));
返回我的那些3列Cake\I18n\Time
实例,如它说here
我该如何避免这种情况?
编辑:
我想这样做的原因是因为当我有类似44:00:00
上expected_hours
它失败
DateTime::modify(): Failed to parse time string (44:00:00) at position 0 (4): Un
expected character
这仅接受24:00:00
或更少...
欢迎任何想法
在你WeeksTable
类补充一点:
use Cake\Database\Schema\Table as Schema;
...
protected function _initializeSchema(Schema $schema)
{
$schema->columnType('initial_date', 'string');
$schema->columnType('final_date', 'string');
$schema->columnType('expected_hours', 'string');
return $schema;
}
这将迫使该模式系统治疗那些列,只是字符串。
我这样做了,它抛出我声明App \ Model \ Table \ WeeksTable :: _ initializeSchema()应该与Cake \ ORM \ Table :: _ initializeSchema兼容(Cake \ Database \ Schema \ Table $ table)' –
好吧我解决了这个问题,并解决了你的问题,但问题仍然存在,'initial_date'和'final_date'工作正常,但是当我添加'expected_hours'来为字符串服务器提供一个' 503'错误 –
你不想要物体的原因是什么? –
更新了原因的问题 –