尊龙凯时人生就是搏

thinkphpÐÞ¸Ä×Ö¶Î

Ëæ×Åweb¿ª·¢ÊÖÒÕµÄһֱǰ½ø £¬¿ò¼ÜÊÖÒÕÔ½À´Ô½³ÉÊì £¬thinkphp×÷Ϊһ¿î¿ªÔ´µÄphp¿ª·¢¿ò¼Ü £¬ÔÚ¿ª·¢ÁìÓòÈ¡µÃÁ˲»´íµÄÊг¡·Ý¶î ¡£ÔÚʹÓÃthinkphp¿ª·¢ÏîĿʱ £¬¾­³£ÐèÒª¶ÔÊý¾Ý¿âÖеÄ×ֶξÙÐÐÐÞ¸Ä ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphp¾ÙÐÐ×ֶεÄÐÞ¸Ä ¡£

Ò»¡¢ÔÚThinkPHPÖÐÐÞ¸Ä×ֶεÄÒªÁì

1.ʹÓÃMigration

ThinkPHPÖеÄMigration¿ÉÒÔ×ÊÖúÎÒÃǾÙÐÐÊý¾Ý¿âǨáã £¬°üÀ¨½¨Éè±í¡¢É¾³ý±í¡¢Ìí¼Ó×ֶΡ¢ÐÞ¸Ä×ֶεȲÙ×÷ ¡£ÔÚ¾ÙÐÐ×ֶεÄÐÞ¸Äʱ £¬ÎÒÃÇÊ×ÏÈÐèÒªÌìÉúMigrationµÄÎļþ ¡£ÔÚÏÂÁîÐÐÖÐʹÓÃÈçÏÂÏÂÁîÌìÉúMigrationÎļþ£º

php think make:migration alter_table_field

µÇ¼ºó¸´ÖÆ

´Ëʱ £¬ThinkPHP½«ÔÚÓ¦ÓÃĿ¼µÄdatabase/migrations/Ŀ¼ÏÂÌìÉúÒ»¸öÃûΪ20210101010101_alter_table_field.phpµÄPHPÎļþ ¡£ÔÚ¸ÃÎļþÖÐ £¬ÎÒÃÇÐèÒª±àдÐÞ¸Ä×ֶεIJÙ×÷ ¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

2.ÐÞ¸ÄMigrationÎļþ

ÐÞ¸ÄMigrationÎļþµÄ·½·¨ÈçÏ£º

£¨1£©ÔÚup()ÒªÁìÖÐŲÓÃSchema::table()ÒªÁì £¬Ö¸¶¨ÐèÒªÐÞ¸Ä×ֶεıíÃû £¬È磺

Schema::table('user', function (Blueprint $table) {
    //
});

µÇ¼ºó¸´ÖÆ

£¨2£©ÔÚSchema::table()ÒªÁìÖÐ £¬Ê¹ÓÃ$table->xxx()ÒªÁìÐÞ¸Ä×ֶΠ¡£ÀýÈç £¬½«name×ֶθÄΪusername £¬¿ÉÒÔʹÓÃÈçÏ´úÂ룺

Schema::table('user', function (Blueprint $table) {
    $table->renameColumn('name', 'username');
});

µÇ¼ºó¸´ÖÆ

£¨3£©ÔÚdown()ÒªÁìÖбàд»Ø¹ö²Ù×÷ ¡£ÀýÈç £¬½«username×ֶλعöΪname×ֶΠ£¬¿ÉÒÔʹÓÃÈçÏ´úÂ룺

Schema::table('user', function (Blueprint $table) {
    $table->renameColumn('username', 'name');
});

µÇ¼ºó¸´ÖÆ

3.Ö´ÐÐMigration

ÐÞ¸ÄMigrationÎļþºó £¬ÐèÒªÖ´ÐÐMigration¾ÙÐÐÊý¾Ý¿âǨáã ¡£ÔÚÏÂÁîÐÐÖÐʹÓÃÈçÏÂÏÂÁîÖ´ÐÐMigration£º

php think migrate

µÇ¼ºó¸´ÖÆ

´Ëʱ £¬ThinkPHP½«ÒÀ´ÎÖ´ÐÐËùÓÐδִÐйýµÄMigrationÎļþÖеIJÙ×÷ ¡£

¶þ¡¢×¢ÖØÊÂÏî

1.ÐÞ¸Ä×Ö¶ÎʱӦעÖØ×Ö¶ÎÀàÐ͵ļæÈÝÐÔ £¬ÀýÈç²»¿É½«ÕûÐÍ×ֶθÄΪ×Ö·ûÐÍ×ֶΠ¡£

2.ÐÞ¸Ä×Ö¶ÎʱӦעÖØÊý¾ÝµÄ¼æÈÝÐÔ £¬ÀýÈçÈôÐÞ¸Ä×Ö·ûÐÍ×ֶεij¤¶È £¬Ó¦È·±£Ð޸ĺóµÄ³¤¶È×ã¹»´æ´¢ÒÑÓÐÊý¾Ý ¡£

3.ÔÚÐÞ¸Ä×Ö¶ÎʱӦעÖرíÖÐÊÇ·ñ±£´æ¸Ã×ֶΠ£¬Èô²»±£´æÓ¦ÏÈÌí¼Ó×ֶκóÔÙ¾ÙÐÐÐÞ¸Ä ¡£

Èý¡¢×ܽá

ÔÚʹÓÃThinkPHP¿ª·¢ÏîĿʱ £¬ÓÉÓÚÐèÇóµÄת±ä»òÕßÆäËûÔµ¹ÊÔ­ÓÉ £¬¿ÉÄÜÐèÒª¶ÔÊý¾Ý¿âÖеÄ×ֶξÙÐÐÐÞ¸Ä ¡£±¾ÎÄÏÈÈÝÁËʹÓÃThinkPHPµÄMigration¾ÙÐÐ×Ö¶ÎÐ޸ĵÄÒªÁì £¬Í¬Ê±Ò²ÌáÐÑÁËÔÚÐÞ¸Ä×Ö¶ÎʱÐèҪעÖصÄÊÂÏî ¡£Ï£Íû±¾ÎÄÄÜ×ÊÖú¶ÁÕ߸üºÃµØʹÓÃThinkPHP¾ÙÐпª·¢ ¡£

ÒÔÉϾÍÊÇthinkphpÐÞ¸Ä×ֶεÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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