尊龙凯时人生就是搏

thinkphp¹¤¾ßд·¨

thinkphpÊÇÒ»¸öºÜÊÇÊ¢ÐеÄphp¿ª·¢¿ò¼Ü£¬ËüÄܹ»×Ô¶¯»¯µØÍê³ÉÐí¶àͨË×´úÂëд×÷£¬ÉÁ¿ª·¢ÕßÔ½·¢¸ßЧ£¬½ÚÔ¼¿ª·¢Ê±¼ä¡£ÆäÖУ¬thinkphpµÄ¹¤¾ßÔòÊÇÆäÔ½·¢¸ßЧµÄ°ü¹Ü£¬¿ÉÒÔ¿ìËÙÍê³ÉһЩ³£¼ûµÄ¹¦Ð§£¬ÀýÈçÊý¾Ý¿â²Ù×÷¡¢»º´æ¿ØÖÆ¡¢ÎļþÉÏ´«µÈµÈ¡£

ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«Ñ§Ï°ThinkPHP¹¤¾ßµÄʹÓÃÒªÁ죬ʹÄãÄܹ»Ô½·¢ÊìÁ·µØÔËÓÃÕâ¸ö¿ò¼Ü£¬Ìá¸ß¿ª·¢Ð§ÂÊ¡£

Êý¾Ý¿â²Ù×÷

ÔÚThinkPHPÖУ¬ÓÐÐí¶àÓÃÓÚ²Ù×÷Êý¾Ý¿âµÄÒªÁì¡£ÆäÖÐ×î³£ÓõÄÊÇDbÀ࣬ʹÓÃÕâ¸öÀà¿ÉÒÔÖ´ÐÐһЩ»ù´¡µÄÔöɾ¸Ä²é²Ù×÷¡£ÒÔÏÂÊÇÒ»¸öʹÓÃDbÀàÅÌÎÊÊý¾Ý¿âµÄÀý×Ó£º

use thinkDb;

// ÅÌÎÊÓû§Áбí
$users = Db::name('user')->select();

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬Db::name(‘user’)ÌåÏÖÅÌÎÊij¸öÊý¾Ý±í¡£ÔÚÕâÒ»²½ÖУ¬ÎÒÃÇ¿ÉÒÔÖ¸¶¨Ãü¾Ý¿âÅþÁ¬¡¢±íÃû¡¢ÓÖÃû¡¢Ö÷¼üµÈÐÅÏ¢¡£ÔÚÓ¦ÓóÌÐòÖУ¬ÎÒÃÇͨ³£ÔÚconfig/database.phpÎļþÖÐÉèÖÃÊý¾Ý¿âÅþÁ¬ÐÅÏ¢¡£

ͨ¹ýselect()ÒªÁìÅÌÎʳöËùÓÐÇкÏÌõ¼þµÄ¼Í¼²¢·µ»Ø£¬ÕâÀïµÄ$usersÔòÊÇÒ»¸ö°üÀ¨ËùÓÐÓû§¼Í¼µÄÊý×é¡£

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

ÔÚÅÌÎÊÊý¾Ý¿âʱ£¬ÎÒÃÇÓпÉÄÜÐèÒªÖ´ÐÐһЩÓÐÌõ¼þµÄÅÌÎÊ£¬´ËʱÎÒÃÇ¿ÉÒÔÔÚDb::name()ºóÃæÌí¼ÓһЩÅÌÎÊÌõ¼þ£¬ÀýÈ磺

// ÅÌÎÊÄêËêΪ18ËêµÄÓû§Áбí
$users = Db::name('user')->where('age', 18)->select();

µÇ¼ºó¸´ÖÆ

±ðµÄ£¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃinsert()¡¢update()ºÍdelete()ÒªÁìÀ´Ö´ÐвåÈë¡¢¸üкÍɾ³ý²Ù×÷¡£

// ²åÈëÒ»¸öÐÂÓû§
Db::name('user')->insert([
    'username' => 'ÕÅÈý',
    'age' => 20,
    'sex' => 1,
]);

// ¸üÐÂÓû§ÐÅÏ¢
Db::name('user')->where('id', 1)->update([
    'username' => 'ÀîËÄ',
    'age' => 22,
]);

// ɾ³ýÖ¸¶¨Óû§
Db::name('user')->where('id', 1)->delete();

µÇ¼ºó¸´ÖÆ

»º´æ¿ØÖÆ

»º´æÊÇÌá¸ßÍøÕ¾ÐÔÄܵÄÖ÷Òª×é³É²¿·Ö¡£ÔÚThinkPHPÖУ¬¿ÉÒÔʹÓûº´æ¹¤¾ßº¯Êý¿ìËÙʵÏÖ»º´æ¹¦Ð§¡£ÒÔÏÂÊÇÒ»¸ö»ù´¡µÄ»º´æ¿ØÖÆÀý×Ó£º

use thinkCache;

// ÏÈÅÌÎÊ»º´æÖÐÊÇ·ñÓÐÓû§Áбí£¬ÈôÊÇûÓÐÔòÅÌÎʲ¢»º´æ
if (!$users = Cache::get('users')) {
    $users = Db::name('user')->select();
    Cache::set('users', $users);
}

// ʹÓÃ$users¾ÙÐÐÓªÒµÂß¼­´¦Àí

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇʹÓÃCacheÀàÖеÄget()ÒªÁìÀ´»ñÈ¡»º´æÄÚÈÝ£¬ÈôÊÇ»º´æÄÚÈݲ»±£´æ£¬ÔòʹÓÃDbÀàÅÌÎÊÊý¾Ý£¬²¢Ê¹ÓÃset()ÒªÁ콫ÅÌÎÊЧ¹û»º´æÆðÀ´¡£ÕâÑù×ö¿ÉÒÔ×èÖ¹Öظ´ÅÌÎÊÊý¾Ý¿â£¬Ìá¸ßÊý¾Ý»áÊÕЧÂÊ¡£

ÔÚÏÖʵ¿ª·¢ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÐí¶àÖÖ²î±ðµÄ»º´æÇý¶¯£¬ÀýÈçÎļþ»º´æ¡¢Redis»º´æ¡¢Memcached»º´æµÈ¡£Í¬Ê±£¬¿ÉÒÔÉèÖûº´æÖÜÆÚ¡¢»º´æ¼üµÄǰ׺¡¢»º´æÃû¿Õ¼äµÈµÈ¡£ÔÚconfig/cache.phpÎļþÖпÉÒÔÉèÖûº´æµÄĬÈÏÇý¶¯ºÍһЩ»º´æ²ÎÊý¡£

ÎļþÉÏ´«

ÔÚÏÖʵ¿ª·¢ÖУ¬¾­³£ÐèÒªÉÏ´«Îļþ¡£ÔÚThinkPHPÖУ¬¿ÉÒÔʹÓÃUploadFileÀàÀ´Íê³ÉÎļþÉÏ´«¡£ÒÔÏÂÊÇÒ»¸öÎļþÉÏ´«µÄÀý×Ó£º

use thinkacadeRequest;
use thinkacadeFilesystem;

// »ñÈ¡ÉÏ´«µÄÎļþ¹¤¾ß
$file = Request::file('image');

// ʹÓÃFilesystemÉÏ´«Îļþ
$path = 'uploads/';

// ÉÏ´«²¢ÉúÑÄÎļþ
$file->validate(['size' => 1024 * 1024 * 2])->move($path);

// Êä³öÉÏ´«ÎļþµÄÐÅÏ¢
echo $file->getInfo('name'), ' ÉÏ´«Àֳɣ¬ÉúÑÄ·¾¶Îª ', $path . $file->getSaveName();

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇÊ×ÏÈͨ¹ýRequestÀà»ñÈ¡ÉÏ´«µÄÎļþ¹¤¾ß¡£È»ºó£¬ÎÒÃÇʹÓÃFilesystemÀཫÎļþÉÏ´«µ½Ö¸¶¨µÄĿ¼£¬²¢Ö¸¶¨ÁËÒ»¸öÎļþ¾ÞϸÑéÖ¤µÄÌõ¼þ¡£×îºó£¬ÎÒÃÇÊä³öÁËÎļþµÄÏà¹ØÐÅÏ¢£¬ÀýÈçÎļþÃûºÍÉúÑÄ·¾¶¡£

ÔÚconfig/filesystem.phpÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÉèÖÃĬÈϵÄÎļþϵͳÇý¶¯£¬ÀýÈçÍâµØÎļþϵͳÇý¶¯¡¢FTPÎļþϵͳÇý¶¯µÈ¡£Õâ¸öÎļþϵͳÇý¶¯»á±»ÓÃÓÚÔÚÓ¦ÓÃÖпìËÙ½¨ÉèºÍÉÏ´«µ½Îļþϵͳ¡£

ͨ¹ýѧϰÒÔÉÏÕâЩÀý×Ó£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ÔÚThinkPHPÖÐʹÓù¤¾ßÀàÊǺÜÊǼòÆӵģ¬²¢ÇÒÄܹ»´ó·ù¶ÈÌá¸ßÎÒÃǵĿª·¢Ð§ÂÊ¡£ÔÚÏÖʵµÄ¿ª·¢ÖУ¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃÆäËûµÄ¹¤¾ßÀàÍê³É¸ü¶àµÄ²Ù×÷£¬ÀýÈçÓʼþ·¢ËÍ¡¢¶ÌÐÅ·¢ËÍ¡¢ÑéÖ¤ÂëÌìÉúµÈµÈ¡£ÔÚÎĵµÖпÉÒÔÕÒµ½¸ü¶àµÄʹÓÃÒªÁìºÍʾÀý´úÂ룬¿ÉÒÔÏêϸÏàʶºÍѧϰ¡£

ÒÔÉϾÍÊÇthinkphp¹¤¾ßд·¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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