×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõôʹÓÃThinkPHPʵÏÖÎÄÕÂÌí¼Ó½çÃæ

Ò»¡¢½¨ÉèÊý¾Ý¿â

Ê×ÏÈ£¬ÎÒÃÇÐèҪΪÎÒÃǵÄÎÄÕÂÌí¼ÓÒ³Ã潨ÉèÒ»¸öÊý¾Ý¿â¡£·­¿ªphpMyAdmin»òÆäËûÊý¾Ý¿âÖÎÀí¹¤¾ß£¬½¨ÉèÒ»¸öÃûΪ¡°blog¡±µÄÊý¾Ý¿â£¬²¢ÔÚÆäÖн¨ÉèÒ»¸öÃûΪ¡°article¡±µÄÊý¾Ý±í¡£Êý¾Ý±íµÄ×ֶΰüÀ¨£ºid(ÎÄÕµÄID)£¬title(ÎÄÕµÄÎÊÌâ)£¬content(ÎÄÕµÄÄÚÈÝ)£¬create_time(ÎÄÕµĽ¨Éèʱ¼ä)£¬update_time(ÎÄÕµĸüÐÂʱ¼ä)¡£

¶þ¡¢½¨ÉèÄ£×Ó£¬¿ØÖÆÆ÷ºÍÊÓͼ

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½¨ÉèÄ£×Ó¡¢¿ØÖÆÆ÷ºÍÊÓͼ£¬ÒÔ¼°ÏìÓ¦µÄ²Ù×÷ÒªÁì¡£ÎÒÃÇÐèÒªÏȽ¨ÉèÒ»¸öArticleÄ£×Ó£¬ÕâÑù¾Í¿ÉÒÔËæʱ»ñÈ¡ÎÄÕÂÊý¾Ý¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÔÚThinkPHPÖУ¬½¨ÉèÄ£×ÓºÜÊǼòÆÓ£¬Ö»ÐèÔÚapplicationĿ¼ÏµÄcommonĿ¼Ï½¨ÉèÒ»¸öArticle.phpÎļþ£¬²¢½«ÒÔÏ´úÂëÌí¼Óµ½ÆäÖУº

<?php
namespace app\common\model;

use think\Model;

class Article extends Model
{
    //±íÃû
    protected $table = 'article';
}

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸ö¿ØÖÆÆ÷£¬¸Ã¿ØÖÆÆ÷ÓÃÓÚ´¦ÀíÎÄÕµÄÌí¼Ó²Ù×÷ÒÔ¼°äÖȾÎÄÕÂÌí¼ÓÒ³Ãæ¡£

ÔÚThinkPHPÖУ¬½¨Éè¿ØÖÆÆ÷Ò²ºÜÊǼòÆÓ£¬Ö»ÐèÔÚapplicationĿ¼ÏµÄadminĿ¼Ï½¨ÉèÒ»¸öArticle.phpÎļþ£¬²¢½«ÒÔÏ´úÂëÌí¼Óµ½ÆäÖУº

<?php
namespace app\admin\controller;

use think\Controller;
use app\common\model\Article;

class Article extends Controller
{
    public function add()
    {
        if(request()->isPost()){
            $data = input('post.');
            $data['create_time'] = time();
            $data['update_time'] = time();
            $article = new Article();
            if($article->allowField(true)->save($data)){
                $this->success('Ìí¼ÓÀֳɣ¡');
            }
            $this->error('Ìí¼Óʧ°Ü£¡');
        }
        return view();
    }
}

µÇ¼ºó¸´ÖÆ

¸Ã¿ØÖÆÆ÷µÄaddÒªÁì±»ÓÃÓÚ·ºÆðÎÄÕÂÌí¼ÓÒ³Ãæ²¢´¦ÀíÌí¼ÓÎÄÕµIJÙ×÷¡£ÔÚÉúÑÄÎÄÕÂʱ£¬ÐèÒª½«ÎÊÌâ¡¢ÄÚÈÝ¡¢½¨Éèʱ¼äºÍ¸üÐÂʱ¼ä´æ´¢ÔÚÊý¾Ý¿â±íÖС£

×îºó£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÊÓͼ£¬¸ÃÊÓͼÓÃÓÚÏÔʾÎÄÕÂÌí¼Ó½çÃæ¡£ÔÚapplicationĿ¼ÏµÄadminĿ¼Ï½¨ÉèÒ»¸öarticle/add.htmlÎļþ£¬²¢½«ÒÔÏ´úÂëÌí¼Óµ½ÆäÖУº

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Ìí¼ÓÎÄÕÂ</title>
</head>
<body>
    <form action="" method="post">
        <div>
            <label for="title">ÎÊÌ⣺</label>
            <input type="text" name="title" id="title">
        </div>
        <div>
            <label for="content">ÄÚÈÝ£º</label>
            <textarea name="content" id="content" cols="30" rows="10"></textarea>
        </div>
        <div>
            <input type="submit" value="Ìí¼Ó">
            <input type="reset" value="ÖØÖÃ">
        </div>
    </form>
</body>
</html>

µÇ¼ºó¸´ÖÆ

Èý¡¢²âÊÔÎÄÕÂÌí¼Ó½çÃæ

Íê³ÉÒÔÉÏ°ì·¨ºó£¬ÎÒÃÇÒѾ­¿ÉÒÔ²âÊÔÎÒÃǵÄÎÄÕÂÌí¼Ó½çÃæÁË¡£ÔÚä¯ÀÀÆ÷ÖÐÊäÈë¡°http://your_domain/admin/article/add¡±£¬¼´¿É»á¼ûÎÄÕÂÌí¼ÓÒ³Ãæ¡£Òª½«ÎÄÕÂÉúÑĵ½Êý¾Ý¿âÖУ¬Ö»ÐèÔÚÒ³ÃæÖÐÌîдÎÄÕÂÎÊÌâºÍÄÚÈÝ£¬È»ºóµã»÷¡°Ìí¼Ó¡±°´Å¥¡£

ÒÔÉϾÍÊÇÔõôʹÓÃThinkPHPʵÏÖÎÄÕÂÌí¼Ó½çÃæµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ