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

我刚开始使用 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');
   }

迁移.php

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

        if (!$this->migration->version(1))
        {
            show_error($this->migration->error_string());
        }
    }

迁移.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;


$config['migration_path'] = APPPATH.'migrations/';

我的错误:

回答

为了解决这个问题,我们必须更深入地了解名为“CI_Migration”的父类。我有 php8.0,它在默认的 Codeigniter 3.2.0-dev 设置下工作不正确,正好是这一行:

elseif ( ! is_callable(array($class, $method)))

在文件系统/库/Migration.php

但是在 3.1.0 版本中,这行看起来像这样。

elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class))))

正是这个选项奏效了。


以上是迁移Codeigniter3中没有有效的“向上”方法的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>