query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $sharTime=$rowset[0]['sharTimeLine']; if ($sharTime !=0){ exit; } write_log("method:shareTimeLine有调用"); $addCode="SELECT TOP 1 id,lotteryCode FROM lottery_code"; $addResult=$pdo->query($addCode); $addRowset = $addResult->fetchAll(PDO::FETCH_ASSOC); $addErrinfo=$pdo->errorInfo(); if ($addErrinfo[0] =="00000"){ $addLotteryCode=$addRowset[0]['lotteryCode']; $addId=$addRowset[0]['id']; //$id=2; $updateSql="UPDATE lottery_user SET sharTimeLine=1 WHERE id=".$updateId; write_log($updateSql); $updateResult=$pdo->exec($updateSql); $insertSql="INSERT INTO lottery_friends(openId,lotteryCode,createtime) VALUES('".$openId."',".$addLotteryCode.",'".date("Y-m-d H:i:s",time())."')"; $insertResult=$pdo->exec($insertSql); $delSql="DELETE FROM lottery_code WHERE id=".$addId; $delResult=$pdo->exec($delSql); $result= json_encode(array("errorcode"=>0,"errorcode"=>"分享朋友圈成功")); } }else{ $result= json_encode(array("errorcode"=>0,"errorcode"=>"多次分享朋友圈只能获得一个抽奖码")); } } echo $result; } ?>