本文整理汇总了PHP中model::has方法的典型用法代码示例。如果您正苦于以下问题:PHP model::has方法的具体用法?PHP model::has怎么用?PHP model::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: likeAction
function likeAction()
{
if ($this->isget()) {
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbe73369f870a0158&redirect_uri=http%3a%2f%2fh5.jiang-mei.com%2fyiboh5%2fcms%2fcp%2flike%2f?id=" . $_GET['id'] . "&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
$this->getToken($url);
//获取记录详情
$map['id'] = $_GET['id'];
$model = new sevenListModel();
$info = $model->get('*', $map);
//获取当天任务详情
$set = $model->table('seven_set')->get('*', array('id' => 1));
$start = $set['start'] ? $set['start'] : strtotime(date('Ymd'));
$rule = $model->table('seven_rule')->get('*', array('times' => ($info['addtime'] - $start) / 86400 + 1));
$this->assign('rule', $rule);
//获取点赞人数
$like = $model->table('like')->count(array('sid' => $_GET['id']));
$info['like'] = $like;
$this->assign('info', $info);
//判断当前用户是否点赞
$where['sid'] = $_GET['id'];
$where['openid'] = $_SESSION['openid'];
$is_like = $model->has(array('AND' => $where));
$this->assign('is_like', $is_like);
$this->display();
} else {
$map['sid'] = $_POST['id'];
$map['openid'] = $_SESSION['openid'];
$model = new model('like');
if ($model->has(array('AND' => $map))) {
$this->json('您已经点过赞了', 0);
} else {
if ($model->insert($map)) {
$this->json('点赞成功');
} else {
$this->json('点赞失败', 0);
}
}
}
}
示例2: setAction
function setAction()
{
$model = new model();
$model->table('seven_set');
$data['start'] = strtotime($_POST['start']);
$data['end'] = strtotime($_POST['end']);
$data['rule'] = $_POST['rule'];
if ($model->has(array('id' => 1))) {
$rs = $model->update($data, array('id' => 1));
} else {
$rs = $model->insert($data);
}
if ($rs) {
$this->json('操作成功');
} else {
$this->json('操作失败', 0);
}
}