我正在尝试使用 CodeIgniter 4 crud 函数 findAll ,并且收到传递给 CodeIgniter\Database\BaseResult::getResult() 的错误参数 1,如下所示:
这是我的模型
<?php
namespace App\Models\Admin\User_management;
use CodeIgniter\Model;
class UsuariosModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
protected $returnType = 'array';
protected $allowedFields = ['user_login', 'user_psw', 'user_full_name', 'user_email', 'user_telef', 'user_image', 'user_date_of_birth', 'user_gender', "user_created_at", "user_updated_at", "user_deleted_at"];
protected $useTimestamps = true;
protected $useSoftDeletes = true;
protected $createdField = 'user_created_at';
protected $updatedField = 'user_updated_at';
protected $deletedField = 'user_deleted_at';
这是我的控制器
public function delete_users(){
//$this->validateViewUserData();
//$user_id = $this->request->getVar('user_id', FILTER_SANITIZE_STRING);
//$this->deleteUsers($user_id);
$user_model = new UsuariosModel();
$users = $user_model->findAll();
}
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_login` varchar(40) NOT NULL,
`user_psw` varchar(255) NOT NULL,
`user_full_name` varchar(100) NOT NULL,
`user_email` varchar(80) NOT NULL,
`user_telef` int(16) NOT NULL,
`user_image` varchar(255) DEFAULT NULL,
`user_created_at` datetime NOT NULL,
`user_updated_at` datetime DEFAULT NULL,
`user_deleted_at` datetime DEFAULT NULL,
`user_date_of_birth` date NOT NULL,
`user_gender` int(1) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=119 DEFAULT CHARSET=utf8;
其他粗略的功能,如更新、保存、删除,运行良好,只有当我使用 find() 或 findAll() 时,它们在控制器和模型本身中不起作用
慕的地8271018
达令说
元芳怎么了
Cats萌萌
森栏
慕侠2389804