<?php use org\rhaco\store\db\Q; \test\model\DateTime::find_delete(); $obj = new \test\model\DateTime(); $obj->ts('2015/07/21 12:13:14')->save(); $obj = new \test\model\DateTime(); $obj->ts('2015/07/22 12:13:14')->save(); $obj = new \test\model\DateTime(); $obj->ts('2015/07/23 13:13:14')->save(); $obj = new \test\model\DateTime(); $obj->ts('2015/07/21 14:13:14')->save(); eq(array('2015/07/21 00:00:00', '2015/07/22 00:00:00', '2015/07/23 00:00:00'), \test\model\DateTime::find_distinct('ts', Q::date_format('ts', 'Ymd'))); eq(array('2000/01/01 12:00:00', '2000/01/01 13:00:00', '2000/01/01 14:00:00'), \test\model\DateTime::find_distinct('ts', Q::date_format('ts', 'H')));
$obj = new \test\model\InitHasParent(); $columns = $obj->columns(); eq(2, sizeof($columns)); foreach ($columns as $column) { eq(true, $column instanceof \org\rhaco\store\db\Column); } \test\model\ExtraInitHasParent::create_table(); $result = \test\model\ExtraInitHasParent::find_all(); \test\model\DateTime::create_table(); \test\model\DateTime::find_delete(); $obj = new \test\model\DateTime(); eq(null, $obj->ts()); eq(null, $obj->date()); eq(null, $obj->idate()); $obj->save(); foreach (\test\model\DateTime::find() as $o) { eq(null, $o->ts()); eq(null, $o->date()); eq(null, $o->idate()); } \test\model\AddNowDateTime::create_table(); \test\model\AddNowDateTime::find_delete(); $obj = new \test\model\AddNowDateTime(); eq(null, $obj->ts()); eq(null, $obj->date()); eq(null, $obj->idate()); $obj->save(); foreach (\test\model\AddNowDateTime::find() as $o) { neq(null, $o->ts()); neq(null, $o->date()); neq(null, $o->idate());
<?php use org\rhaco\store\db\Q; \test\model\DateFormat::create_table(); \test\model\DateTime::find_delete(); $date = strtotime('2015/07/04 12:34:56'); $obj = new \test\model\DateFormat(); $obj->ts($date); $obj->num(10); $obj->save(); foreach (\test\model\DateFormat::find() as $o) { eq(date('Y/m/d H:i:s', $date), $o->fm_ts()); } foreach (\test\model\DateFormat::find(Q::date_format('ts', 'Ym')) as $o) { eq(date('Y/m/01 00:00:00', $date), $o->fm_ts()); } $date = strtotime('2015/07/01 12:34:56'); $obj = new \test\model\DateFormat(); $obj->ts($date); $obj->num(20); $obj->save(); $date = strtotime('2015/07/30 12:34:56'); $obj = new \test\model\DateFormat(); $obj->ts($date); $obj->num(30); $obj->save(); foreach (\test\model\DateFormat::find(Q::date_format('ts', 'Ym')) as $o) { eq(date('Y/m/01 00:00:00', $date), $o->fm_ts()); } $date = strtotime('2015/08/30 12:34:56'); $obj = new \test\model\DateFormat();