尊龙凯时人生就是搏

thinkphpÖÐinɾ³ýÒªÁìµÄʹÓúÍÓ¦Óó¡¾°ÊÇʲô

Ò»¡¢Ê²Ã´ÊÇinɾ³ýÒªÁì

inɾ³ýÒªÁìͨ³£Ê¹ÓÃÒ»¸ö°üÀ¨¶à¸öÖµµÄÊý×é×÷ΪÌõ¼þ£¬ÔÚÊý¾Ý¿âÖÐɾ³ýÇкÏÕâЩÌõ¼þµÄ¶àÌõ¼Í¼¡£ºÃ±ÈÏÂÃæµÄÒ»ÌõSQLÓï¾ä£º

DELETE FROM user WHERE id IN (1, 2, 3, 4, 5);

Óû§±íÖÐidΪ1¡¢2¡¢3¡¢4¡¢5µÄ¼Í¼½«±»´ÓSQLÓï¾äÖÐɾ³ý¡£ÕâÖÖÖðһɾ³ýÒªÁì»ùÓÚSQLÓï¾äµÄÍ·ÄÔ¶øÀ´£¬ËüʹµÃÎÒÃÇÖ´ÐÐÕâÖÖ²Ù×÷Ô½·¢±ã½Ý¡£

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

¶þ¡¢ÔõÑùʹÓÃinɾ³ýÒªÁì

ÔÚThinkPHPÖУ¬inɾ³ýÒªÁìµÄʹÓúÜÊǼòÆÓ£¬Ö»ÐèҪŲÓÃÄ£×ÓµÄdeleteÒªÁ죬²¢´«ÈëÒ»¸ö°üÀ¨¶à¸öÖµµÄÊý×é¼´¿É¡£ÏÂÃæÊÇÒ»¸öʾÀý´úÂ룺

$user = new UserModel();

$ids = array(1, 2, 3, 4, 5);

$result = $user->where(‘id’, ‘in’, $ids)->delete();

ÎÒÃÇÊ×ÏÈʵÀý»¯ÁËÒ»¸öUserModel£¬½«Æ丳¸ø$user±äÁ¿£¬½Ó׎ç˵ÁËÒ»¸ö$idsÊý×飬ÆäÖаüÀ¨¶à¸öidÖµ¡£½Ó×Å£¬ÎÒÃÇŲÓÃÁË$userµÄwhereÒªÁ죬´«ÈëÁË¡¯in¡¯×÷Ϊ½ÏÁ¿·û£¬ÒÔ¼°$idsÊý×飬ÌåÏÖÅÌÎÊÓû§idΪ$idsÊý×éÖеÄí§ÒâÒ»¸öµÄ¼Í¼¡£×îÖÕ£¬ÎÒÃÇʹÓÃÁËdeleteÒªÁ죬ɾ³ýÁËÇкÏÌõ¼þµÄ¼Í¼£¬²¢½«Ð§¹û´æ´¢ÔÚ$result±äÁ¿ÖС£

Èý¡¢inɾ³ýÒªÁìµÄÓ¦Óó¡¾°

inɾ³ýÒªÁìÔÚÐí¶à³¡¾°Ï¶¼ºÜÊÇÓÐÓá£ÀýÈ磬ÎÒÃÇ¿ÉÒÔÔËÓÃinɾ³ýÒªÁ죬ɾ³ýÌض¨·ÖÀàϵÄËùÓÐÎÄÕ£¬Ò²¿ÉÒÔɾ³ý¶à¸öÓû§¡£ÏÂÃæÊÇһЩinɾ³ýÒªÁìµÄ³£¼ûÓ¦Óó¡¾°£º

1.ÅúÁ¿É¾³ýÓû§

¼ÙÉèÎÒÃÇÓÐÒ»¸öÓû§ÖÎÀíϵͳ£¬ÐèҪʵÏÖÅúÁ¿É¾³ý¶à¸öÓû§¡£ÎÒÃÇ¿ÉÒÔʹÓÃinɾ³ýÒªÁìÀ´ÊµÏÖÕâ¸ö¹¦Ð§£¬´úÂëʾÀýÈçÏ£º

$user = new UserModel();

$ids = array(1, 2, 3, 4, 5);

$result = $user->where(‘id’, ‘in’, $ids)->delete();

Õâ¶Î´úÂ뽫ɾ³ýidΪ1¡¢2¡¢3¡¢4¡¢5µÄÓû§¼Í¼¡£

2.ÅúÁ¿É¾³ýÎÄÕÂ

ÈôÊÇÎÒÃÇÐèÒªÒ»´ÎÐÔɾ³ýij¸ö·ÖÀàϵÄËùÓÐÎÄÕ£¬¿ÉÒÔ˼Á¿ÔÚ²©¿ÍϵͳÖÐÌí¼ÓÅúÁ¿É¾³ý¹¦Ð§¡£ÎÒÃÇ¿ÉÒÔʹÓÃinɾ³ýÒªÁìÀ´ÊµÏÖÕâ¸ö¹¦Ð§£¬´úÂëʾÀýÈçÏ£º

$article = new ArticleModel();

$ids = array(21, 22, 23, 24, 25);

$result = $article->where(‘category_id’, 10)->where(‘id’, ‘in’, $ids)->delete();

Õâ¶Î´úÂ뽫ɾ³ý·ÖÀàidΪ10£¬ÇÒidΪ21¡¢22¡¢23¡¢24¡¢25µÄÎÄռͼ¡£

ËÄ¡¢×¢ÖØÊÂÏî

1.inɾ³ýÒªÁìÖ»ÄÜɾ³ýÇкÏij¸öÌõ¼þµÄ¶àÌõ¼Í¼£¬²»¿Éɾ³ýÕûÕűí¡£

2.ÔÚʹÓÃinɾ³ýÒªÁìʱ£¬Òª×¢ÖØת´ïµÄ²ÎÊýÊÇÒ»¸öÊý×飬²¢ÇÒ¸ÃÊý×é±ØÐè°üÀ¨¶à¸öÖµ¡£

3.ÔÚʹÓÃinɾ³ýÒªÁìʱ£¬ÎñÐëҪעÖزÎÊýµÄÇå¾²ÐÔ£¬×èÖ¹SQL×¢ÈëµÈΣº¦¡£

ÒÔÉϾÍÊÇthinkphpÖÐinɾ³ýÒªÁìµÄʹÓúÍÓ¦Óó¡¾°ÊÇʲôµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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