mysql cast方法

Db('study_report_day_info_sp')->field('id,rel_id, max(CAST(video_length as SIGNED))  as m')
            ->where('type',$type)
            ->where('coid',$coid)
            ->where('user_id',$user_id)
            ->group('rel_id')
            ->order('video_length desc')
            ->select();

  

CAST 和 CONVERT 两个函数中的 type取值可以为:SIGNEDUNSIGNED, DECIMALDATETIME, DTAETIME

 

Db('course')->connect('rongyue')
                ->field('couid, TIME_TO_SEC(duration) as c')
                ->where(['coid' => $coid])
                ->select();

  

SEC_TO_TIME(second)   秒换算成时分秒

TIME_TO_SEC(date)  时分秒换算成秒

posted @ 2022-04-20 17:32  叫我亚庆  阅读(253)  评论(0)    收藏  举报