亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 yii2 中使用 start_time 和 end_time 獲取 MySql 中已經存在的

如何在 yii2 中使用 start_time 和 end_time 獲取 MySql 中已經存在的

PHP
元芳怎么了 2022-10-28 15:46:13
我有tbl_batch哪個idtitlestart_datestart_timeend_timevenue_idcreated_by在數據庫中 start_time 和 end_time 被保存為time()排:-id 1title teststart_time 10:10end_time 11:30venue_id 1start_date 2020-03-01 (Y-m-d)created_by 1所以我想檢查時間是否在給定start_time的.end_timestart_date我試過的查詢:-$model = Batch::find()->where(['start_date' => '2020-03-01','venue_id' => 1])->andWhere(['AND',[ '>=',  'start_time',  '10:20'],[ '<=',  'end_time',  '19:20']]);if($model->exists()){      echo 'Already exists in DB';}else{      echo 'Does not Exist';}這沒有返回正確的輸出。
查看完整描述

1 回答

?
達令說

TA貢獻1821條經驗 獲得超6個贊

我終于想通了:)



   $time_between = Batch::find()->where([

                   'start_date' => '2020-03-01',

                   'venue_id' => 1

                ])->andWhere([


                    'OR',

                    [

                        'OR',


                        [

                            'between',

                            'end_time',

                            $model->start_time,

                            $model->end_time

                        ],

                        [

                            'between',

                            'start_time',

                            $model->start_time,

                            $model->end_time

                        ]

                    ],

                    [


                        'AND',

                        [

                            '<=',

                            'start_time',

                            $model->start_time

                        ],

                        [

                            '>=',

                            'end_time',

                            $model->start_time

                        ]

                    ]

                ]);


查看完整回答
反對 回復 2022-10-28
  • 1 回答
  • 0 關注
  • 125 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號