Select

select is for retrieving a single row in the table.

// DB()->select($columns, $table, $whereParams = '')->get();

<?php

namespace App\Controllers;

class UserController
{
    public function index()
    {
        $user_data = DB()->select("*", "users", "id = 2")->get();

        return view('/index', compact('user_data'));
    }
}

The get method return the result of the query where each result is an array. You may access each column's value by accessing the column like this $user_data['fullname'].

Last updated