Welcome Guest, Not a member yet? Register   Sign In
can someone help me change function to run codeigniter 4 ?

(This post was last modified: 01-25-2022, 02:52 AM by startup.)

i have two function below:
PHP Code:
public function vlChos(){
        $query "SELECT id, name FROM categories WHERE parent_id = '429' ";
          return $query->getResultArray();
function 1  working in codeigniter 4

function 2
PHP Code:
public function vlDemo(){
        return $rs;

function 2 dont working in codeigniter 4,

can someone help me rewrite function 2 to working in codeigniter 4 ?

thank you in a advance

note for newbaby to start learn codeigniter 4 like me

we use builder to connect  to database
PHP Code:
public function vlDemos(){
        $builder $this->db->table("categories");
        $query $builder->get();
        return $query->getResult();

i write this function , code perfect in codeigniter

stop help thank you very much

Glad that you figured that out, but that's how i would write it

PHP Code:
public function vlDemos(int $parent_id 429){
  return $this->db->table('categories')
              ->select('id, name')


Theme © iAndrew 2016 - Forum software by © MyBB