Redbean O/RM商店的“日期"作为varchar(255)? [英] Redbean O/RM store "date" as varchar(255)?

查看:79
本文介绍了Redbean O/RM商店的“日期"作为varchar(255)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从此代码:

$toolbox = RedBean_Setup::kickstartDev("mysql:*****************");

$r = $toolbox->getRedBean();

$test = $r->dispense("test");
$test->nom = 'Test #1';
$test->date = '2010-07-08';
$test->date_deux = '08/07/2010';
$test->num = 5;

$id = $r->store( $test ); 

我得到此SQL:

CREATE TABLE IF NOT EXISTS `test` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `nom` varchar(255) collate utf8_unicode_ci default NULL,
  `date` varchar(255) collate utf8_unicode_ci default NULL,
  `num` tinyint(3) unsigned default NULL,
  `date_deux` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;

--
-- Dumping data for table `test`
--

INSERT INTO `test` (`id`, `nom`, `date`, `num`, `date_deux`) VALUES
(1, 'Test #1', '2010-07-08', NULL, NULL),
(2, 'Test #1', '2010-07-08', 5, NULL),
(3, 'Test #1', '2010-07-08', 5, '08/07/2010'),
(4, 'Test #1', '2010-07-08', 5, '08/07/2010'),
(5, 'Test #1', '2010-07-08', 5, '08/07/2010');

是否可以将date与RedBean一起使用?

is there a special way to use date with RedBean?

推荐答案

找到了这个:

优化器现在将转换列 与日期时间值 datetimefields.如果值不同 插入的列将是 OODB在流体模式下将其还原.

The Optimizer will now convert columns with datetime values to datetimefields. If a different value is inserted the column will be reverted by OODB in fluid mode.

这篇关于Redbean O/RM商店的“日期"作为varchar(255)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆