thinkphpÅúÁ¿É¾³ý
ÔÚʹÓÃthinkphp¿ò¼Ü±àдÏîÄ¿µÄʱ¼ä£¬ÎÒÃǾ³£»áÓöµ½ÐèÒªÅúÁ¿É¾³ýÊý¾ÝµÄÇéÐΡ£ÈôÊÇÖ»ÊÇɾ³ýµ¥¶ÀµÄÒ»ÌõÊý¾Ý£¬Ê¹Óÿò¼Ü×Ô´øµÄdeleteÒªÁì¼´¿ÉÍê³É¡£¿ÉÊÇ£¬ÈôÊÇÐèÒªÅúÁ¿É¾³ýÊý¾Ýʱ£¬ÎÒÃÇÐèҪʹÓÃÆäËûÒªÁì¡£
Ò»¡¢Ê¹ÓÃselectÒªÁìÅÌÎÊҪɾ³ýµÄÊý¾Ý
Ê×ÏÈ£¬ÎÒÃÇÐèҪʹÓÃselectÒªÁìÅÌÎÊҪɾ³ýµÄÊý¾Ý£¬²¢½«Êý¾Ý´æÈëÒ»¸öÊý×éÖУº
$ids = input('post.ids/a'); $data = Db::table('table_name')->where('id', 'in', $ids)->select();
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬$ids´ú±íÇ°¶Ë´«À´µÄҪɾ³ýµÄÊý¾ÝµÄidÖµ¡£ÎÒÃÇʹÓÃwhereÒªÁìɸѡ³öidÔÚ$idsÖеÄÊý¾Ý£¬²¢½«Æä´æÈë$dataÊý×éÖС£
¶þ¡¢Ê¹ÓÃforeachÒªÁìÑ»·É¾³ýÊý¾Ý
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
½ÓÏÂÀ´£¬ÎÒÃÇ¿ÉÒÔʹÓÃforeachÒªÁì±éÀú$dataÊý×飬²¢Ê¹Óÿò¼Ü×Ô´øµÄdeleteÒªÁìÀ´É¾³ýÊý¾Ý£º
foreach ($data as $value) { Db::table('table_name')->where('id', $value['id'])->delete(); }
µÇ¼ºó¸´ÖÆ
ÔÚÑ»·Àú³ÌÖУ¬ÎÒÃÇʹÓÃwhereÒªÁìɸѡ³öÄ¿½ñÊý¾ÝµÄidÖµ²¢¾ÙÐÐɾ³ý²Ù×÷¡£
Èý¡¢Ê¹ÓÃDbÀàµÄbatchDeleteÒªÁìÅúÁ¿É¾³ýÊý¾Ý
ÁíÍ⣬thinkphp¿ò¼Ü»¹ÌṩÁËÒ»¸öÅúÁ¿É¾³ýÊý¾ÝµÄÒªÁ졪¡ªbatchDelete¡£ÎÒÃÇ¿ÉÒÔÖ±½ÓʹÓÃÕâ¸öÒªÁìÀ´Íê³ÉÅúÁ¿É¾³ýÊý¾ÝµÄ²Ù×÷£º
$ids = input('post.ids/a'); Db::table('table_name')->where('id', 'in', $ids)->batchDelete();
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬batchDeleteÒªÌå»áƾ֤whereÒªÁìɸѡµÄÌõ¼þ£¬Ö±½Ó½«ÅÌÎʵ½µÄËùÓÐÊý¾Ý¾ÙÐÐɾ³ý²Ù×÷¡£
×ܽá
ÒÔÉϾÍÊÇʹÓÃthinkphp¿ò¼ÜÅúÁ¿É¾³ýÊý¾ÝµÄÒªÁ죬»ù±¾¶¼ÊÇʹÓÃwhereÒªÁìÀ´É¸Ñ¡³öҪɾ³ýµÄÊý¾Ý£¬²¢¾ÙÐÐÑ»·É¾³ý»òÖ±½ÓÅúÁ¿É¾³ý¡£¹ØÓÚ´ó×ÚÊý¾ÝµÄɾ³ý£¬½¨ÒéʹÓÃbatchDeleteÒªÁ죬¿ÉÒÔÌá¸ßɾ³ýЧÂÊ¡£ÎÞÂÛʹÓÃÄÄÖÖÒªÁ죬¶¼ÐèÒªÌØÊâСÐÄ£¬È·±£²»»áÎóɾ³ýÊý¾Ý¡£
ÒÔÉϾÍÊÇthinkphpÅúÁ¿É¾³ýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡