日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

127.0.0.1 zxt.php_get.php · zxt./angularJS - Gitee.com

發布時間:2024/1/8 php 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 127.0.0.1 zxt.php_get.php · zxt./angularJS - Gitee.com 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

error_reporting(E_ALL ^ E_NOTICE);

header("Access-Control-Allow-Orgin:*");

include 'db.class.php';

$db = new db();

/*數據庫連接語句*/

$db->mysql('localhost', 'root', '', 'angular', 'leo_', 'utf8');

//print_r($_GET);exit;

extract($_GET, EXTR_SKIP);

extract($_POST, EXTR_SKIP);

/**

* 列表

*/

if ($action == 'get_list') {

$limit = $order = '';

if (is_numeric($offset) && is_numeric($rows)) {

$limit = " LIMIT $offset,$rows";

}

$orderBy = empty($orderBy) ? 'DESC' : $orderBy;

if (is_string($orderField)) {

$order = " ORDER BY $orderField $orderBy";

}

$where = empty($where) ? '' : $db->format_condition($where);

$sql = "SELECT a.*,b.typename,b.reid FROM `leo_article` AS a INNER JOIN `leo_arctype` AS b ON a.typeid = b.id $where $order $limit";

$list = $db->query($sql)->fetchall();

// $list = $db->fetchall('article', '*', "$where", "$order", "$limit");

echo json_encode($list);

return;

}

/**

* 添加文章

* @param string $title 文章標題

* @param string $content 文章內容

* @param string $typename 所屬分類

* @return

*/

if ($action == 'add_article') {

if (empty($title)) {

$reArr['errors']['title'] = '標題必須';

}

if (empty($content)) {

$reArr['errors']['content'] = '內容必須';

}

if (empty($typeid['id'])) {

$reArr['errors']['typeid'] = '分類必須';

}

if (empty($title) || empty($content) || empty($typeid['id'])) {

echo json_encode($reArr);

return;

}

//判斷分類是否存在

$id = $db->rowcount('arctype', array('id' => "$typeid[id]"));//官

if (!$id) {

echo json_encode(array('code' => 103));

return;

}

$result = $db->insert('article', array('title' => "$title", 'content' => "$content", 'typeid' =>"$typeid[id]", 'addtime' => time()));

if ($result) {

//返回添加的數據的ID

echo json_encode(array('article_id' => $db->lastinsertid()));

return;

}

echo json_encode(array('code' => 102));

return;

}

/**

* 獲得一篇文章

*/

if ($action == 'get_article') {

$sql = "SELECT a.*,b.typename,b.reid FROM `leo_article` AS a INNER JOIN `leo_arctype` AS b ON a.typeid = b.id WHERE a.id = $id";

$data = $db->query($sql)->fetch();

// $data = $db->fetch('article', '*', array('id' => $id));

if ($data) {

echo json_encode($data);

return;

}

echo json_encode(array('code' => 102));

return;

}

/**

* 更新

*/

if ($action == 'update_article') {

if (empty($title)) {

$reArr['errors']['title'] = '標題必須';

}

if (empty($content)) {

$reArr['errors']['content'] = '內容必須';

}

if (empty($typeid)) {

$reArr['errors']['typeid'] = '分類必須';

}

if (empty($title) || empty($content) || empty($typeid)) {

echo json_encode($reArr);

return;

}

$result = $db->update('article', array('title' => "$title", 'content' => "$content", 'typeid' => "$typeid"), array('id' => $id));

$code = $result ? 101 : 102;

echo json_encode(array('code' => $code));

return;

}

/**

* 刪除

* @param string $id

* @return void

*/

if ($action == 'delete_article') {

$result = $db->delete('article', array('id' => "$id"));

$code = $result ? 101 : 102;

echo json_encode(array('code' => $code));

return;

}

/**

* 根據條件返回總頁數$sum

*/

if ($action == 'get_total') {

// $num = empty($num) || $num == 0 ? 10 : $num;

$where = empty($where) ? '' : $where;

$sum = $db->rowcount('article', $where);

// $total = ceil($sum/$num);

echo json_encode(array('total' => $sum));

return;

}

/**

* 獲取所有分類

*/

if ($action == 'get_arctype') {

$where = empty($where) ? '' : $where;

$arctype = $db->fetchall('arctype', '*',"$where");

if ($arctype) {

echo json_encode($arctype);

return;

}

echo json_encode(array('code' => 102));

return;

}

/**

* 用戶登錄

*/

//aciton=login&username=lzy&password=admin參數

if ($action == 'login') {

$reArr = array('success' => false);

//用戶名為空的情況下

if (empty($username)) {

$reArr['errors']['username'] = '用戶名必須';

}

//密碼為空的情況下

if (empty($password)) {

$reArr['errors']['password'] = '密碼必須';

}

if (empty($username) || empty($password)) {

//數組轉化為JSON格式

echo json_encode($reArr);

return;

}

$result = $db->fetch('user', 'id', array('username' => $username, 'password' => $password));

if ($result) {

echo json_encode(array('success' => true, 'message' => '操作成功'));

return;

}

echo json_encode(array('success' => false , 'message' => '用戶名密碼錯誤'));

return;

}

echo json_encode(array('status' => 'error'));

return;

一鍵復制

編輯

Web IDE

原始數據

按行查看

歷史

總結

以上是生活随笔為你收集整理的127.0.0.1 zxt.php_get.php · zxt./angularJS - Gitee.com的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。