尊龙凯时人生就是搏

thinkphp Dº¯ÊýÔõÑùת´ï²ÎÊý

Ò»¡¢Dº¯Êý¼ò½é

Dº¯ÊýÊÇThinkPHPÖг£ÓõÄʵÀý»¯Ä£×Ó¹¤¾ßµÄÒªÁ죬ÆäÓï·¨ÃûÌÃÈçÏ£º

D('Ä£×ÓÃû','Ó¦ÓÃÃû');

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬Ä£×ÓÃûÊDZØÐèµÄ²ÎÊý¡£Ó¦ÓÃÃûÊÇ¿ÉÑ¡µÄ²ÎÊý£¬ÈôÊDz»Ö¸¶¨£¬ÔòĬÒÔΪĿ½ñÓ¦Ó᣺ñȣ¬ÈôÊÇÎÒÃÇҪʵÀý»¯BlogÄ£×Ó£¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$Blog = D('Blog');

µÇ¼ºó¸´ÖÆ

¶þ¡¢Dº¯ÊýÔõÑùת´ï²ÎÊý

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

ΪÁ˸üºÃµØ´¦ÀíÓªÒµÂß¼­£¬ÔÚ¿ª·¢ÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒªÏòÄ£×ÓµÄÌض¨ÒªÁìת´ï²ÎÊý¡£ÒÔÏ´úÂë¿ÉÒÔ±»ÓÃÓÚÅÌÎÊ´óÓÚ20ËêµÄÓû§Áбí

$User = D('User');
$list = $User->getUsersByAge(20);

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖеÄgetUsersByAgeÊÇÒ»¸ö×Ô½ç˵µÄUserÄ£×ÓÒªÁ죬ÓÃÓÚ°´ÄêËêÅÌÎÊÓû§ÐÅÏ¢¡£ÈôÊÇÎÒÃÇÐèҪʹÓÃDº¯ÊýÀ´ÊµÀý»¯UserÄ£×Ó¹¤¾ß£¬²¢Å²ÓÃgetUsersByAgeÒªÁ죬¸ÃÔõÑùת´ï²ÎÊýÄØ£¿

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏàʶDº¯ÊýµÄµÚ¶þ¸ö²ÎÊý£ºÓ¦ÓÃÃû¡£ÔÚĬÈÏÇéÐÎÏ£¬Ó¦ÓÃÃûÊÇÄ¿½ñÓ¦ÓõÄÃû³Æ¡£ÒªÔÚÆäËûÓ¦ÓóÌÐòÖÐʵÀý»¯Ä£×Ó¹¤¾ß£¬Ö»ÐèÖ¸¶¨¸ÃÓ¦ÓóÌÐòµÄÃû³Æ¼´¿É¡£ÀýÈ磬ÈôÒªÔÚAdminÓ¦ÓóÌÐòÖн¨ÉèÒ»¸öUserÄ£×Ó¹¤¾ßµÄʵÀý£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$User = D('User','Admin');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬’Admin’ÌåÏÖÓ¦ÓÃÃû¡£ÔÚÕâÖÖÇéÐÎÏ£¬AdminÓ¦ÓóÌÐò½«ËÑË÷UserÄ£×ÓÒÔʵÀý»¯¹¤¾ß£¬´Ó¶øʹDº¯ÊýµÃÒÔÕý³£ÔËÐС£È»¶ø£¬ÎÒÃÇÈÔÐèÕÒµ½Ò»ÖÖÒªÁìÀ´×ª´ï²ÎÊý¸øUserÄ£×ÓÖеÄgetUsersByAgeÒªÁì¡£

Õë¶ÔÕâ¸öÎÊÌ⣬ThinkPHPÌṩÁËÒ»ÖÖÔ½·¢¾«Á·µÄд·¨¡£ÎÒÃÇ¿ÉÒÔʹÓÃDº¯ÊýµÄµÚÈý¸ö²ÎÊý£¬ÓÃÓÚת´ï²ÎÊý¡£ÒÔÏ´úÂë¿ÉÒÔÓÃÀ´ÅÌÎÊÄêËêÁè¼Ý20ËêµÄÓû§Áбí

$User = D('User','','');
$list = $User->getUsersByAge(20);

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖУ¬µÚÒ»¸ö¿Õ×Ö·û´®´ú±íÄ£×ÓÃû³Æ£¬µÚ¶þ¸ö¿Õ×Ö·û´®´ú±íÓ¦ÓÃÃû³Æ£¬µÚÈý¸ö¿Õ×Ö·û´®ÓÃÓÚת´ï²ÎÊý¡£ÔÚgetUsersByAgeÒªÁìÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃfunc_get_args()º¯ÊýÀ´»ñȡת´ïµÄ²ÎÊý¡£

Èý¡¢ÊµÀý

ÎÒÃÇʵÑéÔÚThinkPHP5.0ÏîÄ¿Öн¨ÉèÒ»¸öÃûΪBlogµÄÄ£¿é£¬¾ÙÐÐÏÖʵ²Ù×÷¡£ÔÚBlogÄ£¿éÖн¨ÉèÒ»¸öArticle¿ØÖÆÆ÷£¬²¢Ìí¼ÓindexÒªÁ죬ÓÃÓÚÅÌÎÊID´óÓÚ10ÇÒ״̬Ϊ1µÄÎÄÕÂÁбí¡£´úÂëÈçÏ£º

// ÎļþµØµã£ºapplication\blog\controller\Article.php
namespace app\blog\controller;
use think\Controller;
class Article extends Controller
{
    public function index()
    {
        $Blog = D('Blog','Common');
        $list = $Blog->getArticlesById(10,1);
        dump($list);
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇʹÓÃDº¯ÊýʵÀý»¯ÁËÒ»¸öBlogÄ£×Ó¹¤¾ß£¬²¢Ö¸¶¨ÁËÓ¦ÓÃÃû’Common’¡£ÎÒÃÇʹÓÃÁËBlogÄ£×ÓÖеÄ×Ô½ç˵ҪÁìgetArticlesById£¬ÒÔÅÌÎÊÇкÏÌõ¼þµÄÎÄÕÂÁбí¡£getArticlesByIdÒªÁìµÄ´úÂëÈçÏ£º

// ÎļþµØµã£ºapplication\common\model\Blog.php
namespace app\common\model;
use think\Model;
class Blog extends Model
{
    protected $table = 'blog';
    public function getArticlesById($id,$status)
    {
        $where = [
            'id' => ['gt',$id],
            'status' => $status
        ];
        return $this->where($where)->select();
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃǽç˵ÁËÒ»¸öÅÌÎÊID´óÓÚ10ÇÒ״̬Ϊ1µÄÎÄÕÂÁбíµÄÒªÁìgetArticlesById¡£¸ÃÒªÁì½ÓÊÜÁ½¸ö²ÎÊý£¬»®·ÖÊÇ$idºÍ$status¡£Í¨¹ýʹÓÃwhereÒªÁìÉèÖÃÅÌÎÊÌõ¼þ£¬ÎÒÃÇ×îÖÕͨ¹ýselectÒªÁì·µ»ØÁËÅÌÎÊЧ¹û¡£

ÒÔÉϾÍÊÇthinkphp Dº¯ÊýÔõÑùת´ï²ÎÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ