protected function init() { session_start(); if (empty($_SESSION['user_info']) || empty($_POST['content'])) { echo 'error'; exit; } else { $content = $_POST['content']; $id = $_POST['id']; $name = $_SESSION['user_info']['nickname']; $header = $_SESSION['user_info']['header']; if (empty($header)) { $header = 'http://7xngw8.com1.z0.glb.clouddn.com/title.png'; //默认头像 } $local_db = new lhh_db(); //检验是不是重复参与的,并计入参与人数 $num = $local_db->count('dbd_comment', '*', array('AND' => array('u_name' => $name, 'dbd_id' => $id))); if (empty($num)) { $local_db->update('dbd_list', array('count[+]' => 1), array('id' => $id)); } date_default_timezone_set('PRC'); $re = $local_db->insert('dbd_comment', array('u_name' => $name, 'header' => $header, 'dbd_id' => $id, 'content' => $content, 'time' => time(), 'up' => 0)); if ($re > 0) { echo 'ok'; } else { echo 'fail'; } } }
protected function init() { $local_db = new lhh_db(); $re = $local_db->select('dbd_list', '*', array('ORDER' => 'time DESC', 'LIMIT' => [0, 1])); if (empty($re)) { echo ''; } else { echo json_encode($re[0]); } }
protected function init() { date_default_timezone_set('PRC'); $local_db = new lhh_db(); $re = $local_db->insert('lhh_comment', array('u_name' => $_POST['name'], 'lhh_id' => $_POST['id'], 'time' => time(), 'content' => $_POST['text'])); if (!empty($re)) { echo 'ok'; } else { echo 'error'; } }
protected function init() { // date_default_timezone_set('PRC'); $local_db = new lhh_db(); $list = $local_db->select('lhh_comment', '*', array('lhh_id' => $_POST['id'])); if (empty($list)) { echo 'none'; } else { echo json_encode($list); } }
protected function insert_into_database($auth, $type, $append, $content) { $local_db = new lhh_db(); // print_r($local_db); date_default_timezone_set('PRC'); $re = $local_db->insert('lhh_list', array('header' => 'http://7xnquu.com1.z0.glb.clouddn.com/app_icon.png', 'auth' => $auth, 'type' => $type, 'append' => $append, 'content' => $content, 'time' => time(), 'up' => 0, 'down' => 0, 'comment' => 0)); if (!empty($re)) { echo '上传成功!'; } else { echo '上传失败!'; } }
protected function init() { $id = $_POST['id']; $index = $_POST['index']; $type = $_POST['type']; $local_db = new lhh_db(); if ($type == 'rank') { $re = $local_db->select('dbd_comment', '*', array('dbd_id' => $id, 'ORDER' => ['up DESC', 'time ASC'], 'LIMIT' => [0, 5])); if (!empty($re)) { echo json_encode($re); } else { echo 'error'; } } else { $re = $local_db->select('dbd_comment', '*', array('dbd_id' => $id, 'ORDER' => 'time DESC', 'LIMIT' => [$index * $this->page_size, $this->page_size])); if (!empty($re)) { echo json_encode($re); } else { echo 'error'; } } }
<?php /** * Created by PhpStorm. * User: KeenSting * Date: 2015/11/24 * Time: 19:56 */ require 'medoo.php'; $db = new lhh_db(); $id = $_POST['id']; $re = $db->count('dbd_comment', '*', array('dbd_id' => $id)); echo $re;
<?php /** * Created by PhpStorm. * User: KeenSting * Date: 2015/11/24 * Time: 20:47 */ require 'medoo.php'; $id = $_POST['id']; session_start(); if (empty($_SESSION['user_info']) || empty($_POST)) { echo 'error'; exit; } $db = new lhh_db(); $num = $db->count('dbd_record', '*', array('AND' => array('comment_id' => $id, 'uid' => $_SESSION['user_info']['uid']))); if (empty($num)) { $db->update('dbd_comment', array('up[+]' => 1), array('id' => $id)); $db->insert('dbd_record', array('comment_id' => $id, 'uid' => $_SESSION['user_info']['uid'])); echo 'ok'; } else { echo 'repeat'; }