×ðÁú¿­Ê±

thinkphpÊý¾Ý¿âÅÌÎÊÊýÄ¿²Ù×÷ÒªÁì

ÔÚʹÓÃthinkphp¿ò¼Ü¾ÙÐÐÊý¾Ý¿â¿ª·¢Ê±£¬ÅÌÎÊÊý¾ÝµÄÊýÄ¿ÊÇÒ»¸ö·Ç³£»ù´¡µÄ²Ù×÷¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphp¿ò¼ÜÖеÄÊý¾Ý¿âÅÌÎÊÊýÄ¿²Ù×÷ÒªÁ죬×ÊÖú¿ª·¢Õ߸üºÃµØʵÏÖÊý¾ÝÅÌÎʹ¦Ð§¡£

Ò»¡¢ÅÌÎÊ×ÜÊý

ÔÚ¿ª·¢ÖУ¬ÎÒÃÇÐèÒªÅÌÎÊÒ»ÕűíÖеÄ×ܼͼÊý¡£Ê¹ÓÃThinkPHP¿ò¼Ü¾ÙÐÐÅÌÎÊ×ÜÊýÓÐÁ½ÖÖÒªÁ죺

ʹÓÃcountÒªÁì

countÒªÁìÊÇThinkPHPÅÌÎÊÊýÄ¿µÄ±ê×¼ÒªÁ죬¿ÉÒÔºÜÈÝÒ׵طµ»ØÅÌÎÊЧ¹ûµÄ¼Í¼Êý¡£Ê¹ÓÃÒªÁìÈçÏ£º

$count = Db::name('table')->count();

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬tableÊÇÖ¸ÐèÒªÅÌÎʵÄÊý¾Ý±íÃû£¬count()ÒªÁì·µ»ØµÄÊÇ×ܼͼÊý¡£

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

ʹÓÃFindÒªÁì

ÎÒÃÇÒ²¿ÉÒÔʹÓÃFindÒªÁìÀ´»ñÈ¡×ܼͼÊý¡£FindÒªÌå»á·µ»ØÒ»Ìõ¼Í¼£¬²¢ÇҼͼµÄֵΪ±íÖÐËùÓмͼµÄÊýÄ¿¡£Ê¹ÓÃÒªÁìÈçÏ£º

$count = Db::name('table')->field('count(*) as count')->find();

µÇ¼ºó¸´ÖÆ

ÐèҪעÖصÄÊÇ£¬ÕâÀïʹÓÃÁËfield()ÒªÁìÀ´Ö¸¶¨·µ»Ø¼Í¼µÄ×ֶΣ¬ASÓï¾ä·µ»ØµÄÊǼͼÊý¡£

¶þ¡¢ÅÌÎÊÖ¸¶¨Ìõ¼þµÄ×ÜÊý

ÔÚÅÌÎÊÊý¾Ýʱ£¬ÓÐЩʱ¼äÎÒÃÇÐèҪƾ֤ij¸öÌõ¼þÅÌÎÊÇкϸÃÌõ¼þµÄ×ܼͼÊý¡£Ê¹ÓÃThinkPHP¿ò¼Ü¾ÙÐÐÅÌÎÊÖ¸¶¨Ìõ¼þµÄ×ÜÊýÒªÁìÈçÏ£º

ʹÓÃwhereÒªÁì

whereÒªÁìÊÇÓÃÓÚÉèÖÃÅÌÎÊÌõ¼þµÄÒªÁ죬¿ÉÒÔƾָ֤¶¨Ìõ¼þ·µ»ØÇкϸÃÌõ¼þµÄ×ܼͼÊý¡£Ê¹ÓÃÒªÁìÈçÏ£º

$count = Db::name('table')->where('id',1)->count();

µÇ¼ºó¸´ÖÆ

ÅÌÎÊid=1µÄ¼Í¼µÄÊýÄ¿¡£ÈôÊÇÐèÒªÅÌÎʶà¸öÌõ¼þ£¬¿ÉÒÔʹÓÃÊý×éµÄ·½·¨×ª´ï£º

$count = Db::name('table')->where(['id'=>1,'status'=>1])->count();

µÇ¼ºó¸´ÖÆ

ÕâÑù»áÅÌÎÊÖª×ãid=1ÇÒstatus=1µÄ¼Í¼µÄÊýÄ¿¡£

ʹÓÃwhereOrÒªÁì

ÈôÊÇÐèÒªÅÌÎʶà¸öÌõ¼þÖÐÈκÎÒ»¸öÖª×ãÌõ¼þµÄ¼Í¼ÊýÄ¿£¬Ôò¿ÉÒÔʹÓÃwhereOrÒªÁ졣ʹÓÃÒªÁìÈçÏ£º

$count = Db::name('table')->whereOr(['id'=>1,'status'=>1])->count();

µÇ¼ºó¸´ÖÆ

ÕâÑù»áÅÌÎÊÖª×ãid=1»òstatus=1µÄ¼Í¼µÄÊýÄ¿¡£

ÒÔÉϾÍÊÇThinkPHP¿ò¼ÜÖÐÅÌÎÊÊýÄ¿µÄ²Ù×÷ÒªÁì¡£×ܽáһϣ¬countÒªÁìºÍFindÒªÁìÊÇÁ½ÖÖ½ÏÁ¿¼òÆÓµÄÅÌÎʼͼÊýÄ¿µÄÒªÁ죬ÆäÖÐfieldÒªÁìÓÃÀ´ÉèÖ÷µ»ØµÄ×ֶΡ£ÔÚÅÌÎÊij¸öÌõ¼þµÄ¼Í¼ÊýĿʱ£¬¿ÉÒÔʹÓÃwhereÒªÁìÉèÖÃÅÌÎÊÌõ¼þ»òÕßʹÓÃwhereOrÒªÁìÅÌÎʶà¸öÌõ¼þµ±ÖÐÈÎÒ»Ìõ¼þµÄÒÑÓÐÊýÄ¿¡£¹ØÓÚ¿ò¼Ü¿ª·¢ÕßÀ´Ëµ£¬ÕâЩÅÌÎʼͼÊýÄ¿µÄ²Ù×÷ÒªÁ콫´ó´óïÔÌ­¿ª·¢Ê±¼ä¡£

ÒÔÉϾÍÊÇthinkphpÊý¾Ý¿âÅÌÎÊÊýÄ¿²Ù×÷ÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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