首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CodeIgniter 4项目中未定义的常量"CodeIgniter\Database\MySQLi\MYSQLI_STORE_RESULT“

CodeIgniter 4项目中未定义的常量"CodeIgniter\Database\MySQLi\MYSQLI_STORE_RESULT“
EN

Stack Overflow用户
提问于 2021-11-13 02:04:41
回答 1查看 798关注 0票数 0

我已经安装了CodeIgniter项目(4.1.5)与Composer。我在PHP 8.0.12上运行它

当我尝试与数据库通信时,我得到内部服务器错误500,日志消息如下:

代码语言:javascript
复制
CRITICAL - 2021-11-13 01:39:18 --> Undefined constant "CodeIgniter\Database\MySQLi\MYSQLI_STORE_RESULT"
#0 D:\Sites\ea4\vendor\codeigniter4\framework\system\Database\Database.php(56): CodeIgniter\Database\Database->initDriver('MySQLi', 'CodeIgniter\\Dat...', Array)
#1 D:\Sites\ea4\vendor\codeigniter4\framework\system\Database\Config.php(78): CodeIgniter\Database\Database->load(Array, 'default')
#2 D:\Sites\ea4\vendor\codeigniter4\framework\system\Model.php(97): CodeIgniter\Database\Config::connect('default')
#3 D:\Sites\ea4\app\Controllers\Backend\Home.php(33): CodeIgniter\Model->__construct()
#4 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(824): App\Controllers\Backend\Home->index()
#5 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(410): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Backend\Home))
#6 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(318): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#7 D:\Sites\ea4\public\index.php(37): CodeIgniter\CodeIgniter->run()

在Home controller中,我有以下代码:

代码语言:javascript
复制
public function index()
{
    $session = session();
    $data = [];
    // Check for post
    if ($this->request->getMethod() === 'post') {
        // Validate the user input
        if (!($this->validate([
            'cmsuserEmail'      => ['label' => 'E-Mail',                'rules'   => 'required|min_length[6]|max_length[50]|valid_email'],
            'cmsuserPassword'   => ['label' => 'Κωδικός πρόσβασης',     'rules'   => 'required|min_length[8]|max_length[255]'],
        ]))) {
            // Validation has failed, redirect the user back
            return redirect()->to(base_url() . '/Backend/Home/index')->withInput();
        }
        $model = new CmsuserModel();
        $user = $model->where('cmsuserEmail', $this->request->getPost('cmsuserEmail'))->first();
        // If I try to var_dump user, var_dump is not displayed, if I print string "Debug" and die()  one line above, string is printed.

有人知道我为什么会得到这个错误吗?我应该在哪里定义常量MYSQLI_STORE_RESULT吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-13 08:08:16

据我所知,您可以检查是否安装了PHP的mysqli模块。

通过php -m检查您的服务器的cli,您应该将mysqli列为其中一个模块。

我检查了这里的参考资料https://www.php.net/manual/en/mysqli.installation.php

我在一个托管在docker上的CodeIgniter 4文件上使用了这个,我也得到了这个错误。经过一些研究,我只是在映像构建中确保安装/安装了mysqli模块。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69950895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档