getRedBean-6ren">
gpt4 book ai didi

php - Redbean O/RM 将 "date"存储为 varchar(255)?

转载 作者:可可西里 更新时间:2023-11-01 06:36:32 24 4
gpt4 key购买 nike

来自这段代码:

$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 一起使用?

最佳答案

找到这个:http://groups.google.com/group/redbeanorm/browse_thread/thread/6961ac635e6886f6

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.

关于php - Redbean O/RM 将 "date"存储为 varchar(255)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3212917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com