小编mar*_*iro的帖子

迁移 Codeigniter 3 中没有有效的“向上”方法

我刚开始使用 Codeigniter 3,我知道它已经过时了,但任务已设置为可以使用它。而我马上就遇到了问题,在网上翻来覆去,没有找到答案。

在我看来,我只是遗漏了一个小细节。请帮助指导我走上真正的道路。

迁移

class Migration_Add_blog extends CI_Migration {

    public function up()
    {
        $this->dbforge->add_field(array(
            'id' => array(
                'type' => 'INT',
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ),
            'title' => array(
                'type' => 'TEXT',
                'null' => TRUE,
            ),
       ));
        $this->dbforge->add_key('id', TRUE);
        $this->dbforge->create_table('blog');
   }
Run Code Online (Sandbox Code Playgroud)

迁移.php

public function index()
    {
        $this->load->library('migration');

        if (!$this->migration->version(1))
        {
            show_error($this->migration->error_string());
        }
    }
Run Code Online (Sandbox Code Playgroud)

迁移.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');


$config['migration_enabled'] = TRUE;

$config['migration_type'] = 'sequential';

$config['migration_table'] = 'migrations';


$config['migration_auto_latest'] = FALSE;

$config['migration_version'] = 1; …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

3
推荐指数
1
解决办法
462
查看次数

标签 统计

codeigniter ×1

php ×1