ThinkPHPÖÐÔõô¾ÙÐÐÊý¾ÝÅÌÎʺóÌí¼Ó×Ö¶Î
Ò»¡¢ÅÌÎÊÊý¾Ý
ÎÒÃÇÏÈÍù·µÊ×Ò»ÏÂÔõÑùÔÚThinkPHPÖоÙÐÐÊý¾ÝÅÌÎÊ¡£ÔÚ¿ØÖÆÆ÷ÖÐÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ´úÂëÀ´¾ÙÐÐÊý¾ÝÅÌÎÊ£º
$User = M('User'); $list = $User->where('status=1')->select(); $this->assign('list',$list); $this->display();
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂëʵÏÖÁ˶ÔÃûΪUserµÄÊý¾Ý±íÖÐstatus¼´ÊÇ1µÄÊý¾Ý¾ÙÐÐÅÌÎÊ£¬²¢½«ÅÌÎʳöÀ´µÄЧ¹û¸³Öµ¸øÁËlist±äÁ¿¾ÙÐÐչʾ¡£
¶þ¡¢Ìí¼Ó×Ö¶Î
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÈôÊÇÎÒÃÇÐèÒª¶ÔÅÌÎʳöµÄÊý¾ÝÌí¼ÓÒ»¸ö×Ö¶ÎÓÃÀ´¾ÙÐбê¼Ç»òÕßÆäËû²Ù×÷£¬ÐèÒªÔõÑùʵÏÖÄØ£¿
ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÒªÁìΪÅÌÎʳöÀ´µÄÊý¾ÝÌí¼Ó×ֶΣº
$User = M('User'); $list = $User->where('status=1')->select(); foreach ($list as $key=>$val){ $list[$key]['new_field'] = 'new_value'; } $this->assign('list',$list); $this->display();
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂëÖУ¬ÎÒÃÇÔÚÑ»·±éÀúÅÌÎÊЧ¹ûʱ£¬ÐÂÔöÁËÒ»¸önew_field×ֶΣ¬²¢½«ÆäÖµ¸³Îªnew_value¡£ÎÒÃÇÐèҪʹÓÃforeachÓï¾ä¶Ô¶þάÊý×é$list¾ÙÐÐÑ»·±éÀú£¬ÕâÊÇÐèҪעÖصġ£
Èý¡¢ÍêÕû´úÂë
×îÖյĴúÂëÈçÏ£º
$User = M('User'); $list = $User->where('status=1')->select(); foreach ($list as $key=>$val){ $list[$key]['new_field'] = 'new_value'; } $this->assign('list',$list); $this->display();
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇThinkPHPÖÐÔõô¾ÙÐÐÊý¾ÝÅÌÎʺóÌí¼Ó×ֶεÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡