本文整理汇总了PHP中news::add方法的典型用法代码示例。如果您正苦于以下问题:PHP news::add方法的具体用法?PHP news::add怎么用?PHP news::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类news
的用法示例。
在下文中一共展示了news::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
<?php
include "../function.php";
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : "";
if ($action == "add") {
$news = new news();
$result = $news->add();
switch ($result) {
case "success":
error("添加成功!", "alertGoTo", $_SERVER['HTTP_REFERER']);
break;
case "error":
error($news->getActionError(), "alertGoTo", $_SERVER['HTTP_REFERER']);
break;
}
}
if ($action == "doRm") {
$id = isset($_POST["id"]) ? intval($_POST["id"]) : "";
if (empty($id)) {
jsonError("fail", "id为空");
}
$sql = "delete {$mysqlConfig["db_perfix"]}web_news where id = {$id} limit 1";
sqlExecute($sql, "", "json");
jsonError("succ");
}
if ($action == "doMod") {
$news = new news();
$result = $news->modi();
switch ($result) {
case "success":
error("添加成功!", "alertGoTo", $_SERVER['HTTP_REFERER']);
示例2: news
$do = new news();
switch ($action) {
case 'add':
if ($MG['news_limit']) {
$r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}news WHERE username='{$_username}' AND status>0");
if ($r['num'] >= $MG['news_limit']) {
dalert(lang($L['limit_add'], array($MG['news_limit'], $r['num'])), 'goback');
}
}
if ($submit) {
if ($do->pass($post)) {
$post['username'] = $_username;
$post['level'] = $post['addtime'] = 0;
$need_check = $MOD['news_check'] == 2 ? $MG['check'] : $MOD['news_check'];
$post['status'] = get_status(3, $need_check);
$do->add($post);
dmsg($L['op_add_success'], '?status=' . $post['status']);
} else {
message($do->errmsg);
}
} else {
foreach ($do->fields as $v) {
${$v} = '';
}
$content = '';
$typeid = 0;
$type_select = type_select($TYPE, 0, 'post[typeid]', $L['default_type']);
$head_title = $L['news_title_add'];
}
break;
case 'edit':
示例3: json_encode
<?php
error_reporting(E_ERROR);
upload();
$title = $_POST['title'];
$content = $_POST['content'];
$img = upload();
require_once "model.php";
$news = new news();
if ($news->add($title, $content, $img)) {
$data['status'] = 1;
$data['msg'] = "添加成功";
} else {
$data['status'] = 0;
$data['msg'] = "添加失败";
}
echo json_encode($data);
function upload()
{
if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/png") && $_FILES["file"]["size"] < 2000000) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
if (file_exists("upload/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
} else {
$name = $_FILES["file"]["name"];
$ext = array_pop(explode(".", $name));
$name = time() . rand(0, 10000) . "." . $ext;
move_uploaded_file($_FILES["file"]["tmp_name"], "img/" . $name);
return $name;