本文整理匯總了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);
}
}