尊龙凯时人生就是博

laravel ÌÞ³ýÊý¾Ý

ͻ񻣼

Laravel ÊÇÒ»ÖÖÊ¢ÐÐµÄ PHP ¿ª·¢¿ò¼Ü £¬ÊÊÓÃÓÚ½¨Éè Web Ó¦Óá£ÓÐʱ £¬ÎÒÃÇÐèÒªÔÚÊý¾Ý¿âÖÐÌÞ³ýһЩÊý¾Ý £¬Õâ¾ÍÐèÒªÓõ½ Laravel Êý¾Ý¿âÅÌÎʹ¹½¨Æ÷¡£

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓà Laravel Êý¾Ý¿âÅÌÎʹ¹½¨Æ÷À´ÌÞ³ýÊý¾Ý¡£

ÕýÎÄ£º

ÔÚ Laravel ÖÐ £¬É¾³ýÊý¾ÝµÄÒªÁìÓжàÖÖ¡£ÎÒÃÇ¿ÉÒÔʹÓà Eloquent Ä£×Ó£¨ORM£©À´É¾³ý¼Í¼ £¬Ò²¿ÉÒÔʹÓà Query Builder Ö´ÐÐ SQL ÅÌÎÊ´ÓÊý¾Ý¿âÖÐɾ³ý¼Í¼¡£

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃǽ«Ê¹Óà Query Builder À´ÌÞ³ýÊý¾Ý¡£

Ê×ÏÈ £¬ÈÃÎÒÃǼÙÉèÎÒÃÇÓÐÒ»¸öÃûΪ ¡°users¡± µÄ±í¸ñ£¨°üÀ¨ÁË id £¬name ºÍ email ×ֶΣ©¡£

ÏÖÔÚ £¬ÎÒÃÇÐèÒªÌÞ³ý id ¼´ÊÇ 1 µÄ¼Í¼¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

DB::table('users')->where('id', '=', 1)->delete();

µÇ¼ºó¸´ÖÆ

ÕâÀï £¬ÎÒÃÇʹÓà DB Facade À´Ñ¡ÕªÒªÅÌÎʵıí¸ñ £¬²¢Ê¹Óà where() ÒªÁìÀ´ÏÞÖÆÌÞ³ýÄÄЩ¼Í¼¡£delete() ÒªÁìÓÃÓÚ´ÓÊý¾Ý¿âÖÐÌÞ³ý¼Í¼¡£

ÈôÊÇÎÒÃÇÏëҪɾ³ý±í¸ñÖеÄËùÓмͼ £¬ÎÒÃÇ¿ÉÒÔʹÓà truncate() ÒªÁì¡£¸ÃÒªÁ콫ɾ³ýÕû¸ö±í¸ñ £¬²¢ÇÒÖØÖÃ×ÔÔö ID Ϊ 1¡£ÒÔÏÂÊÇÔõÑùʹÓà truncate() ÒªÁìµÄÀý×Ó£º

DB::table('users')->truncate();

µÇ¼ºó¸´ÖÆ

ÔÚÕâÖÖÇéÐÎÏ £¬ÎÒÃÇûÓйýÂËÈκμͼ¡£Òò´Ë £¬Õû¸ö±í¸ñÖеÄËùÓмͼ¶¼½«±»ÌÞ³ý¡£

ÈôÊÇÎÒÃÇÐèҪɾ³ý±í¸ñÖеļͼ £¬µ«Ï£Íû±£´æ±í¸ñ×Ô¼º £¬Ôò¿ÉÒÔʹÓà drop() ÒªÁì¡£¸ÃÒªÁ콫ɾ³ýÕû¸ö±í¸ñ £¬¶ø²»µ«½öÊǼͼ¡£ÒÔÏÂÊÇÔõÑùʹÓà drop() ÒªÁìµÄÀý×Ó£º

Schema::drop('users');

µÇ¼ºó¸´ÖÆ

ÕâÀï £¬ÎÒÃÇʹÓà Schema Facade À´Ñ¡ÕªÒªÉ¾³ýµÄ±í¸ñ £¬²¢Ê¹Óà drop() ÒªÁìÀ´É¾³ý±í¸ñ¡£

½áÂÛ£º

Laravel µÄ Query Builder ÊÇÒ»ÖÖºÜÊÇÓÐÓõŤ¾ß £¬ËüʹÎÒÃÇÄܹ»ÇáËɵشÓÊý¾Ý¿âÖÐÌÞ³ýÊý¾Ý¡£ÔÚ±¾ÎÄÖÐ £¬ÎÒÃÇÏÈÈÝÁËÔõÑùʹÓà Laravel Êý¾Ý¿âÅÌÎʹ¹½¨Æ÷À´ÌÞ³ýÊý¾Ý¡£ÏÖÔÚ £¬Äú¿ÉÒÔÇáËÉɾ³ý Laravel Ó¦ÓóÌÐòÖеļͼ¡£

ÒÔÉϾÍÊÇlaravel ÌÞ³ýÊý¾ÝµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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