Welcome Guest, Not a member yet? Register   Sign In
How to write query on Model and Call Model using Controller in Codeigniter 4?
#1

(This post was last modified: 09-24-2019, 04:50 AM by msjagan.)

I am trying to fetch values from users table but throws error. Can anyone give sample snippet for the query (Select, Insert)?

PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;


class 
UserModel extends Model
{
    protected 
$table                  'users';
    protected $primaryKey             'id';

    protected $allowedFields         = ['username''password'];

 
    public function 
all()
    {
        $users_result $this->db->query('SELECT * FROM users')->result_array();

        return 
$users_result;
    }


Please point out what I am doing wrong with the above code
Reply


Messages In This Thread
How to write query on Model and Call Model using Controller in Codeigniter 4? - by msjagan - 09-24-2019, 01:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB