亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

?? ??? ??
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
??

遷移是以結(jié)構(gòu)化和有組織的方式更改數(shù)據(jù)庫的一種方便的方式。您可以手工編輯SQL片段,但隨后您將負責(zé)告訴其他開發(fā)人員他們需要去運行它們。您還必須跟蹤下次部署時需要針對生產(chǎn)機器運行哪些更改。

數(shù)據(jù)庫表遷移跟蹤哪些遷移已經(jīng)運行,所以您所要做的就是更新應(yīng)用程序文件并調(diào)用$this->migration->current()以確定應(yīng)該運行哪些遷移。當前版本可在application/config/移入.php...

  • 遷移文件名

  • 創(chuàng)建遷移

  • 使用實例

  • 遷移偏好

  • 類引用

遷移文件名

根據(jù)所采用的方法,每個遷移都按數(shù)字順序向前或向后運行。有兩種編號樣式:

  • 順序:每個遷移按順序編號,從001開始。每個數(shù)字必須是三位數(shù)字,并且序列中不得有空位。(這是CodeIgniter 3.0之前的編號方案。)

  • 時間戳:使用YYYYMMDDHHIISS格式(例如20121031100537)創(chuàng)建遷移時,使用時間戳對每個遷移進行編號。這有助于防止在團隊環(huán)境中工作時編號沖突,并且是CodeIgniter 3.0及更高版本中的首選方案。

可以使用$config['migration_type']在你的application/config/移入.php檔案。

無論您選擇使用哪種編號樣式,遷移文件的前綴都是遷移號,后面是下劃線和遷移的描述性名稱。例如:

  • 001_add_blog.php(順序編號)

  • 20121031100537_add_blog.php(時間戳編號)

創(chuàng)建遷移

這將是一個擁有博客的新網(wǎng)站的首次遷移。所有遷移都在application / migrations /目錄中,并具有名稱,如20121031100537_add_blog.php。

<?phpdefined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Add_blog extends CI_Migration {        
    public function up()        {
                $this->dbforge->add_field(array(                        
                    'blog_id' => array('type' => 'INT','constraint' => 5,'unsigned' => TRUE,'auto_increment' => TRUE),
                    'blog_title' => array('type' => 'VARCHAR','constraint' => '100',),'blog_description' => array('type' => 'TEXT','null' => TRUE,),));
                $this->dbforge->add_key('blog_id', TRUE);
                $this->dbforge->create_table('blog');        }        
                public function down()        {
                    $this->dbforge->drop_table('blog');        }
                    }

然后進去application/config/移入.php$config['migration_version'] = 20121031100537;...

使用實例

在這個例子中,一些簡單的代碼放在應(yīng)用程序/控制器/Migrate.php若要更新架構(gòu),請執(zhí)行以下操作:

<?phpclass Migrate extends CI_Controller{        
        public function index(){
                $this->load->library('migration');                
                if ($this->migration->current() === FALSE)                
                {
                    show_error($this->migration->error_string());}
                }
                }

遷移偏好

下面是用于遷移的所有配置選項的表。

偏好

默認

選項

描述

migration_enabled

真假

啟用或禁用遷移。

migration_path

APPPATH.'migrations /”

沒有

您的遷移文件夾的路徑。

migration_version

0

沒有

數(shù)據(jù)庫應(yīng)該使用的當前版本。

migration_table

遷移

沒有

用于存儲模式版本號的表名。

migration_auto_latest

真假

啟用或禁用自動運行遷移。

MIGRATION_TYPE

“時間戳”

'時間戳'/'順序'

用于命名遷移文件的數(shù)字標識符的類型。

類引用

class CI_Migrationcurrent()

返回:

如果未找到遷移,則為TRUE,成功時為當前版本字符串,失敗時為FALSE

返回類型:

mixed

error_string()

返回:

錯誤消息

返回類型:

find_migrations()

返回:

一組遷移文件

返回類型:

數(shù)組

latest()

返回:

成功時的當前版本字符串,失敗時為FALSE

返回類型:

mixed

version($target_version)

參數(shù):

$ target_version(混合) - 將遷移版本處理

返回:

如果未找到遷移,則為TRUE,成功時為當前版本字符串,失敗時為FALSE

返回類型:

mixed

  • $ target_version混合) - 將遷移版本處理

Returns:  TRUE if no migrations are found, current version string on success, FALSE on failure
Return type:  mixed
版本可用于回滾更改或以編程方式前進到特定版本。它像`current()`一樣工作,但忽略`$ config ['migration_version']`。
?? ??: ?? ??: