php - 迁移 Codeigniter 3 中的 "up"方法无效

标签 php codeigniter

我刚开始使用 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/';
我的错误:
enter image description here

最佳答案

为了解决这个问题,我们必须更深入地了解名为“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))))
正是这个选项奏效了。

关于php - 迁移 Codeigniter 3 中的 "up"方法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65405139/

相关文章:

php - Symfony:自定义过滤器/ Hook /事件监听器 - 怎么做?

php - 使用 PHP 函数别名是否性能不佳/不好的做法?

php - select records form tableA and tableB where tableA.id = tableB.id, records from tableA 一次

php - 字符串后如果没有空格,正则表达式 OR 语句将无法工作

php - 在 Silex 应用程序中共享第 3 方依赖项的最佳实践?

php - Codeigniter 多维数组插入数据库

php - Codeigniter数据选择

mysql - 如何将此查询转换为 Codeigniter 事件记录

php - wordpress metaWeblog.newPost xmlrpc 如果不存在则创建类别,并防止来自 codeigniter 的重复标题

php - mysql插入返回多行