×ðÁú¿­Ê±

thinkphp inÅÌÎÊÔõÑù·ÖÒ³

thinkphpÊÇÒ»¸öÆÕ±éʹÓõÄphp¿ò¼Ü £¬ÆäÌṩÁËÇ¿Ê¢µÄÅÌÎʹ¦Ð§ £¬¿ÉÒÔʹÓû§Àû±ãµØÖ´ÐÐÖÖÖÖÖØ´óµÄÅÌÎʲÙ×÷¡£ÆäÖÐ £¬inÅÌÎÊÓï¾äÊdz£ÓõÄÅÌÎÊÓï¾äÖ®Ò»¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphpÖеÄinÅÌÎÊÓï¾äʵÏÖ·ÖÒ³¹¦Ð§¡£

Ò»¡¢Ê²Ã´ÊÇinÅÌÎÊ

ÔÚÏàʶinÅÌÎÊÔõÑù·Öҳ֮ǰ £¬ÎÒÃÇÐèÒªÏÈÏàʶʲôÊÇinÅÌÎÊ¡£ÔÚÊý¾Ý¿âÅÌÎÊÖÐ £¬inÅÌÎÊÓï¾äÊÇÒ»ÖÖÓÃÓÚÔÚ¸ø¶¨Ò»×éÖµµÄÇéÐÎÏ £¬Æ¥ÅäÅÌÎÊÌõ¼þµÄÓï¾ä¡£ÀýÈç £¬ÎÒÃÇÏëÒª²éÕÒÒ»¸öÉÌÆ· £¬ËüµÄÖÖ±ðΪµçÊÓ»òµçÄÔ»òÊÖ»ú £¬ÄÇô¾Í¿ÉÒÔʹÓÃinÅÌÎÊÓï¾ä¡£inÅÌÎÊÓï·¨ÈçÏ£º

SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...);

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬INºóÃæ¸úµÄÊÇÒ»¸öÀ¨ºÅ £¬À¨ºÅÄÚÊÇÖµÁбí¡£ÀýÈ磺

SELECT * FROM products WHERE category_name IN ('ÊÖ»ú', 'µçÄÔ', 'µçÊÓ');

µÇ¼ºó¸´ÖÆ

ÕâÌõSQLÓï¾ä½«»á·µ»ØÖÖ±ðΪÊÖ»ú¡¢µçÄÔ»òµçÊÓµÄÉÌÆ·ÐÅÏ¢¡£

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

¶þ¡¢ÔõÑùʹÓÃinÅÌÎÊʵÏÖ·ÖÒ³

ÏàʶÁËinÅÌÎÊÓï¾äµÄ»ù±¾Ó÷¨ºó £¬ÎÒÃÇ¿ÉÒÔ×îÏȽâ¾öÔõÑùʹÓÃinÅÌÎÊÓï¾äʵÏÖ·ÖÒ³¡£·ÖÒ³ÊÇÖ¸ÔÚÅÌÎʵÄЧ¹û¼¯Öн«Ð§¹û·ÖΪÈô¸ÉÒ³ £¬ÒÔ±ãÓû§¿ÉÒÔÖðÒ³ä¯ÀÀÅÌÎÊЧ¹û¡£ThinkPHPÌṩÁËÇ¿Ê¢µÄ·ÖÒ³¹¦Ð§ £¬¿ÉÒÔÀû±ãµØʵÏÖ·ÖÒ³¹¦Ð§¡£

ÔÚThinkPHPÖÐ £¬·ÖÒ³ÀàλÓÚ\think\paginatorÃüÃû¿Õ¼äÖС£Ê¹Ó÷ÖÒ³¹¦Ð§ÐèÒª¾ÙÐÐÒÔÏÂÈý¸ö°ì·¨£º

1.ÅÌÎÊÊý¾Ý

ʹÓÃinÅÌÎÊÓï¾äÅÌÎʳöÐèÒª¾ÙÐзÖÒ³µÄÊý¾Ý £¬ÀýÈ磺

$goods = Db::name('goods')
         ->where('category_id','in',[1,2,3,4,5])
         ->order('price DESC')
         ->paginate(10);

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄ´úÂ뽫»áÅÌÎʳöÉÌÆ·ÖÖ±ðΪ1¡¢2¡¢3¡¢4¡¢5µÄÉÌÆ· £¬²¢Æ¾Ö¤¼ÛÇ®´Ó¸ßµ½µÍÅÅÐò £¬²¢ÇÒÿҳÏÔʾ10ÌõÊý¾Ý¡£

2.»ñÈ¡·ÖÒ³Êý¾Ý

ͨ¹ýŲÓÃpaginate()ÒªÁì £¬ÎÒÃÇ¿ÉÒÔ»ñÈ¡µ½·ÖÒ³Æ÷¹¤¾ß¡£·ÖÒ³Æ÷¹¤¾ß°üÀ¨Ä¿½ñÒ³Â롢ÿҳÏÔʾµÄÊý¾ÝÊýÄ¿ºÍ×ܹ²µÄÊý¾ÝÌõÊýµÈÐÅÏ¢¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨»ñÈ¡·ÖÒ³Æ÷ÖеÄÊý¾Ý£º

$goods = $goods->items();

µÇ¼ºó¸´ÖÆ

3.äÖȾ·ÖÒ³ÊÓͼ

·ÖÒ³Æ÷¹¤¾ß»¹°üÀ¨ÁË·ÖÒ³ÐÅÏ¢µÄäÖȾҪÁì £¬ÎÒÃÇ¿ÉÒÔʹÓÃÕâЩҪÁìÉúÒòËØÒ³ÊÓͼ¡£ÀýÈ磺

<div>
<?php  echo $goods->render(); ?&gt;</div>

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃÇͨ¹ýrender()ÒªÁìÌìÉúÁË·ÖÒ³Æ÷µÄhtmlÊÓͼ £¬È»ºó½«Æä²åÈëµ½ÁËÒ³ÃæÖС£ÕâÑù £¬ÎÒÃǾÍÍê³ÉÁËʹÓÃinÅÌÎÊÓï¾äʵÏÖ·ÖÒ³µÄ¹¦Ð§¡£

Èý¡¢×ܽá

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃThinkPHPÖеÄinÅÌÎÊÓï¾äʵÏÖ·ÖÒ³¡£inÅÌÎÊÓï¾ä¿ÉÒÔÀû±ãµØ¶Ô¸ø¶¨µÄ¶à¸öÖµ¾ÙÐÐÅÌÎÊ £¬¶ø·ÖÒ³Æ÷Ôò¿ÉÒÔÀû±ãµØ½«Êý¾Ý·ÖÒ³ÏÔʾ¡£ÍŽáʹÓÃÕâÁ½¸ö¹¦Ð§ £¬ÎÒÃÇ¿ÉÒÔÀû±ãµØʵÏÖÖØ´óµÄÅÌÎʺͷÖÒ³¹¦Ð§¡£

ÒÔÉϾÍÊÇthinkphp inÅÌÎÊÔõÑù·ÖÒ³µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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