How to realize the continuous check-in function of ThinkPHP
This article mainly explains "ThinkPHP how to achieve continuous check-in function", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "ThinkPHP how to achieve continuous check-in function" bar!
Table structure
/ * * implementation of continuous check-in * /
Public function signList () {
/ * * find out if this user exists first * /
$m_id = $_ GET ['mSecretid']
$sign = D ('Sign')-> where (array ("m_id" = > $m_id)-> limit (0)-> find ()
/ * * if so, judge the time difference, and then deal with the number of check-ins * /
If ($sign) {
/ * yesterday's timestamp time range * /
$t = time ()
$last_start_time = mktime ("m", $t), date ("d", $t)-1 magic date ("Y", $t))
$last_end_time = mktime (23 and 59 (m), $t), date ("d", $t)-1 ("Y", $t))
/ * Today's timestamp time range * /
/ / $now_start_time = mktime (0Magne0Gram0date ("m", $t), date ("d", $t), date ("Y", $t))
/ / $now_end_time = mktime (23 date 59, $t, date ("d", $t), date ("Y", $t)
/ * * determine whether the last check-in time is within yesterday's time range * /
If ($last_start_time$m_id)-> save ($da)
} else {
/ * * return the checked-in operation * /
$da ['time'] = time ()
$da ['count'] = 0
D ('Sign')-> where (array ("m_id" = > $m_id)-> save ($da)
}
} else {
$data ['mroomid'] = $m_id
$data ['time'] = time ()
$data ['sign'] = 1
$res = D ("Sign")-> add ($data)
If ($res) {
/ * * return if successful, or deal with some programs, such as adding points * /
}
}}
Thank you for reading, the above is the content of "how to achieve continuous check-in function in ThinkPHP". After the study of this article, I believe you have a deeper understanding of how to achieve continuous check-in function in ThinkPHP, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!