【问题标题】:Database backup with codeigniter 4使用 codeigniter 4 进行数据库备份
【发布时间】:2021-04-30 07:50:11
【问题描述】:

我想备份 CI 4 中的数据库。

$model = new class extends \CodeIgniter\Model {
        protected $table      = 'form';
        protected $primaryKey = 'id';
    };
    $db = \Closure::bind(function ($model) {
        return $model->db;
    }, null, $model)($model);
    
    $util = (new \CodeIgniter\Database\Database())->loadUtils($db);

现在我想以 SQL 格式保存表格。 提前致谢。

【问题讨论】:

    标签: database-backups


    【解决方案1】:
    public function backup_db(){
    $model = new class extends \CodeIgniter\Model {
    protected $database      = 'options';
    protected $primaryKey = 'option_id';
        };
        $db = \Closure::bind(function ($model) {
        return $model->db;
        }, null, $model)($model);
    
        $util = (new \CodeIgniter\Database\Database())->loadUtils($db);
        echo $util->getXMLFromResult($model->get());
    }
    

    【讨论】:

    • 除了代码之外,您能补充一点信息吗?
    猜你喜欢
    • 2022-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-04
    • 2011-09-28
    • 1970-01-01
    相关资源
    最近更新 更多