尊龙凯时人生就是搏

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¡¢ÍøÕ¾µØͼ