如何检查 table 列中可用的 ID 在 CodeIgniter 中具有前缀值

how to check the id available in the table column have prefix value in CodeIgniter

我正在为我的项目使用 codeigniter。我已将会员 ID 存储在会员 table 中。成员 ID 模式是“KZI22M8547”。最后 4 位数字是随机的,其余字符是根据表单输入值生成的。我想在创建新成员时检查新成员id(包含最后4位随机数)是否可用

I'm using the following code in the model
$query = $this->db->get_where('members', array(
            'member_id' => $member_id
        ));
        if ($query->num_rows() > 0) {
            return true;
        } else {
            return false;
        }
$this->db->select('SUBSTRING(member_id, 7) as member_id', FALSE);
$query = $this->db->get_where('members', array(
    'ch_id' => $ch_id
))->result();

if (in_array($rand_no, array_column($query, 'member_id'))) {
    return true;
} else {
    return false;
}