thinkphp3ÔõôʵÏÖÔöɾ¸Ä²é
±¾ÎĽ«Îª¸÷ÈËÏÈÈÝthinkphp3¿ò¼ÜϵÄÔöɾ¸Ä²é²Ù×÷£¬Ï£Íû¶ÔÕýÔÚѧϰthinkphp3¿ò¼ÜµÄ¿ª·¢ÕßÓÐËù×ÊÖú¡£
ÔöÌí²Ù×÷
ÔÚThinkPHP3ÖУ¬ÐÂÔöÒ»ÌõÊý¾Ý¿ÉʹÓÃMÒªÁ죬ÀýÈ磺
$Model = M('User'); $data['name'] = 'wuzhi'; $data['password'] = md5('123456'); $result = $Model->add($data);
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂëÒâ˼ÊÇʵÀý»¯UserÄ£×Ó£¬²¢ÎªÆäÉèÖÃnameºÍpasswordÊôÐÔ£¬È»ºóͨ¹ýaddÒªÁ콫Êý¾Ý²åÈëµ½Êý¾Ý¿âÖС£$resultΪ²åÈëºó·µ»ØµÄÖ÷¼üÖµ¡£
ÅÌÎʲÙ×÷
ÅÌÎʵ¥¸öÊý¾ÝÓÃfindÒªÁ죬ÅÌÎʶà¸öÊý¾ÝÓÃselectÒªÁ죬ÀýÈ磺
$Model = M('User'); $condition['id'] = 1; $result = $Model->where($condition)->find();
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂëÒâ˼ΪÅÌÎÊidΪ1µÄÓû§Êý¾Ý²¢·µ»ØЧ¹û¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
$Model = M('User'); $condition['id'] = array('between',array(1,10)); $result = $Model->where($condition)->select();
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂëΪÅÌÎÊidÔÚ1-10Ö®¼äµÄÓû§Êý¾Ý²¢·µ»ØЧ¹û¡£
Ð޸IJÙ×÷
ʹÓÃsaveÒªÁì¶ÔÒÑÓÐÊý¾Ý¾ÙÐÐÐ޸ģ¬ÀýÈ磺
$Model = M('User'); $condition['id'] = 1; $data['name'] = 'lisi'; $data['password'] = md5('654321'); $result = $Model->where($condition)->save($data);
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫idΪ1µÄÓû§µÄnameºÍpasswordÐÞ¸ÄΪÁËlisiºÍ654321¡£
ɾ³ý²Ù×÷
ʹÓÃdeleteÒªÁìɾ³ýÊý¾Ý£¬ÀýÈ磺
$Model = M('User'); $condition['id'] = 1; $result = $Model->where($condition)->delete();
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫idΪ1µÄÓû§Êý¾Ý¾ÙÐÐɾ³ý²Ù×÷¡£
ÒÔÉϾÍÊÇThinkPHP3¿ò¼ÜϵÄÔöɾ¸Ä²é²Ù×÷µÄ»ù±¾ÏÈÈÝ¡£ÔÚÏÖʵ¿ª·¢ÖУ¬ÎÒÃÇÐèÒªÎÞаÔËÓÃÒÔÉÏÒªÁìÀ´ÊµÏÖÖÖÖÖ¹¦Ð§¡£Ï£Íû±¾ÎÄÄܹ»×ÊÖúµ½¸÷ÈË¡£
ÒÔÉϾÍÊÇthinkphp3ÔõôʵÏÖÔöɾ¸Ä²éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡