×ðÁú¿­Ê±

thinkphp5Ìí¼ÓÇóºÍÒªÁìµÄÁ÷³Ì

Ëæ×Å php ÊÖÒÕµÄÉú³¤£¬Ô½À´Ô½¶àµÄ¿ª·¢Õß×îÏȹØ×¢ php ¿ò¼Ü£¬ÆäÖÐ thinkphp 5 ÊÇÒ»¿îÖÜÈ«µÄ php ¿ò¼Ü£¬ÌṩÁËÇ¿Ê¢µÄ¹¦Ð§£¬ÔÚ¿ª·¢Àú³ÌÖÐïÔÌ­Á˳ÌÐò¿ª·¢Ö°Ô±µÄÊÂÇéÁ¿¡£¶øÆäÖеÄÇóºÍÒªÁìÊÇÐí¶à¿ª·¢Õß±ØÐè×öµÄÒ»¸ö²Ù×÷¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«Ñ§Ï° thinkphp 5 ÖеÄÌí¼ÓÇóºÍÒªÁìµÄÁ÷³Ì¡£

µÚÒ»²½£º½¨Éè Model Îļþ

ÔÚ ThinkPHP 5 ÖУ¬ÎÒÃÇÐèÒª×Ô¼º½¨Éè Model ÎļþÀ´Íê³ÉÊý¾Ý²Ù×÷¡£ÎÒÃÇÐèÒªÔÚ application Ŀ¼ÏÂн¨Ò»¸öÃûΪ Sum.php µÄÎļþ£¬´úÂëÈçÏÂËùʾ£º

namespace app\index\model;
use think\Model;

class Sum extends Model
{
    // ÇóºÍÒªÁì
    public function sum()
    {
        $result = $this->sum('field');
        return $result;
    }
}

µÇ¼ºó¸´ÖÆ

ÔڸôúÂëÖУ¬ÎÒÃǽ¨ÉèÁËÒ»¸öÃûΪ Sum µÄ Model Îļþ£¬ÆäÖаüÀ¨ÁËÒ»¸ö sum ÒªÁì¡£¸ÃÒªÁìʹÓÃÁË sum º¯Êý¶ÔÖ¸¶¨×ֶΠfield ¾ÙÐÐÁËÇóºÍ²Ù×÷£¬²¢·µ»ØÇóºÍЧ¹û¡£

µÚ¶þ²½£ºÉèÖÃÊý¾Ý¿âÅþÁ¬

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

ÔÚ ThinkPHP 5 ÖУ¬ÎÒÃÇÐèÒªÔÚÉèÖÃÎļþÖÐÉèÖÃÊý¾Ý¿âÅþÁ¬¡£ÎÒÃÇÐèÒªÔÚ application Ŀ¼Ï嵀 database.php ÎļþÖоÙÐÐÉèÖ㬴úÂëÈçÏÂËùʾ£º

return [
    // Êý¾Ý¿âÀàÐÍ
    'type'            => 'mysql',
    // Ð§ÀÍÆ÷µØµã
    'hostname'        => 'localhost',
    // Êý¾Ý¿âÃû
    'database'        => 'test',
    // Óû§Ãû
    'username'        => 'root',
    // ÃÜÂë
    'password'        => '',
    // ¶Ë¿Ú
    'hostport'        => '',
    // ÅþÁ¬dsn
    'dsn'             => '',
    // Êý¾Ý¿âÅþÁ¬²ÎÊý
    'params'          => [],
    // Êý¾Ý¿â±àÂëĬÈϽÓÄÉutf8
    'charset'         => 'utf8',
    // Êý¾Ý¿â±íǰ׺
    'prefix'          => 'tp_',
];

µÇ¼ºó¸´ÖÆ

ÔڸôúÂëÖУ¬ÎÒÃÇÉèÖÃÁËÊý¾Ý¿âµÄÅþÁ¬ÐÅÏ¢£¬°üÀ¨Êý¾Ý¿âÀàÐÍ¡¢Ð§ÀÍÆ÷µØµã¡¢Êý¾Ý¿âÃû¡¢Óû§ÃûºÍÃÜÂëµÈ¡£È·±£¸ÃÉèÖúÍÄãµÄÊý¾Ý¿âÅþÁ¬ÐÅÏ¢Ò»Ö¡£

µÚÈý²½£ºÊ¹Óà Model Îļþ¾ÙÐвÙ×÷

ÔÚÉèÖúà Model ÎļþºÍÊý¾Ý¿âÅþÁ¬Ö®ºó£¬ÎÒÃǾͿÉÒÔʹÓà Model Îļþ¶ÔÊý¾Ý¿â¾ÙÐвÙ×÷ÁË¡£´úÂëÈçÏÂËùʾ£º

use app\index\model\Sum;

$sum = new Sum();
$result = $sum->sum();
echo $result;

µÇ¼ºó¸´ÖÆ

ÔڸôúÂëÖУ¬ÎÒÃÇʹÓÃÁË Sum Model ÖÐµÄ sum ÒªÁ죬²¢½«ÇóºÍЧ¹ûÊä³ö¡£ÕâÑù£¬ÎÒÃǾÍÀֳɵØÔÚ ThinkPHP 5 ÖÐÇóºÍÁËÖ¸¶¨×ֶΡ£

½áÂÛ

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÌÖÂÛÁËÔõÑùÔÚ ThinkPHP 5 ÖÐʵÏÖÇóºÍ²Ù×÷¡£Ê×ÏÈ£¬ÎÒÃǽ¨ÉèÁËÒ»¸ö Sum Model Îļþ£¬²¢ÔÚÆäÖбàдÁË sum ÒªÁì¡£½Ó×Å£¬ÎÒÃÇÔÚÉèÖÃÎļþÖÐÉèÖÃÁËÊý¾Ý¿âÅþÁ¬ÐÅÏ¢£¬²¢Ê¹Óà Model Îļþ¶ÔÊý¾Ý¿â¾ÙÐÐÁ˲Ù×÷¡£ÎÒ½¨ÒéÄãÇ××Ôʵ¼ùһϣ¬ÒÔ±ã¸üºÃµØÃ÷È· ThinkPHP 5 ÖеÄÇóºÍ²Ù×÷¡£

ÒÔÉϾÍÊÇthinkphp5Ìí¼ÓÇóºÍÒªÁìµÄÁ÷³ÌµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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