ThinkPHPÖÐÔõô¾ÙÐÐÌõ¼þÅÌÎÊ
Ò»¡¢Ê¹ÓÃwhereÒªÁìÌí¼ÓÅÌÎÊÌõ¼þ
ÔÚThinkPHPÖУ¬ÅÌÎÊÌõ¼þ¿ÉÒÔʹÓÃwhereÒªÁìÀ´Ìí¼Ó¡£whereÒªÁìÓÐÁ½¸ö²ÎÊý£ºµÚÒ»¸ö²ÎÊýΪÅÌÎÊÌõ¼þ£¬µÚ¶þ¸ö²ÎÊýΪÅÌÎÊÌõ¼þµÄ°ó¶¨²ÎÊý¡£ÒªÅÌÎÊidΪ1»ò2µÄ¼Í¼£¬ÎÒÃÇ¿ÉÒÔÓÃÒÔÏ´úÂ룺
$map['id'] = array('eq',1); $map['id'] = array('eq',2); $data = M('table_name')->where($map)->select();
µÇ¼ºó¸´ÖÆ
ÎÒÃÇÏȵ¥¶À½ç˵ÁËÅÌÎÊÌõ¼þ£¬Ò»¸öÊÇidΪ1£¬ÁíÒ»¸öÊÇidΪ2£¬È»ºó½«ËüÃÇÌí¼Ó½ø$mapÊý×éÖС£È»ºóÎÒÃÇʹÓÃwhereÒªÁ콫Õâ¸öÊý×éת´ï¸øÅÌÎʲÙ×÷¡£ÅÌÎÊЧ¹û½«·µ»ØÇкÏÌõ¼þµÄ¼Í¼Êý×é¡£
¶þ¡¢Ê¹ÓÃÊý×é·½·¨×ª´ïÅÌÎÊÌõ¼þ
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
³ýÁËÓÃwhereÒªÁ죬ÎÒÃÇÒ²¿ÉÒÔÓÃÊý×é·½·¨×ª´ïÅÌÎÊÌõ¼þ¡£Ê¹ÓÃÕâÖÖ·½·¨£¬ÎÒÃÇÖ»ÐèÒªÔÚ$mapÊý×éÖÐÌí¼ÓÅÌÎÊÌõ¼þ¼´¿É¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂëÀ´ÅÌÎʱíÖÐÄÄЩ¼Í¼µÄid¼´ÊÇ1»ò¼´ÊÇ2
$map['id'] = array('in', '1,2'); $data = M('table_name')->where($map)->select();
µÇ¼ºó¸´ÖÆ
ÎÒÃÇÔÚ´úÂëÖнç˵ÁËÅÌÎÊÌõ¼þ£¬½öÏÞÓÚ $map Êý×éÖÐµÄ id Ϊ 1 »ò 2¡£ÎÒÃÇʹÓÃÁË¡°in¡±ÔËËã·û£¬À´Í³Ò»¼ìË÷idΪ1»ò2µÄ¼Í¼¡£ÕâÑù£¬ÎÒÃǾͿÉÒÔÇáËɵØʵÏÖÉ趨¡°»ò¡±µÄÅÌÎÊÌõ¼þ¡£
Èý¡¢Ê¹ÓÃ×Ö·û´®Æ´½Ó
ÓÐʱ¼ä£¬ÎÒÃÇ¿ÉÒÔʹÓÃ×Ö·û´®Æ´½ÓµÄ·½·¨À´ÊµÏÖ¡°»ò¡±µÄÅÌÎÊÌõ¼þ¡£¾ÙÀý¶øÑÔ£¬ÈôÊÇÎÒÃÇÏëÒª¼ìË÷³ö¼ÈÖª×ãÌõ¼þAÓÖÖª×ãÌõ¼þBµÄ¼Í¼£¬¿ÉÒÔ½ÓÄÉÒÔÏ´úÂ룺
$map['×Ö¶ÎÃû'] = array('exp', '(Ìõ¼þA) OR (Ìõ¼þB)'); $data = M('table_name')->where($map)->select();
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇʹÓÃexp²Ù×÷·ûת´ïÁËÒ»Ìõ°üÀ¨Á½¸öÌõ¼þµÄSQLÓï¾ä¡£×¢ÖØ£¬ÕâÀïÌõ¼þÐèҪʹÓÃÀ¨ºÅÀ¨ÆðÀ´ÒÔÈ·±£Â߼׼ȷ¡£
ÒÔÉϾÍÊÇThinkPHPÖÐÔõô¾ÙÐÐÌõ¼þÅÌÎʵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡