Struggling to solve this error. Didn't understand it
Model:
public function join()
{
$db=\Config\Database::connect();
$session=\Config\Services::session();
$id=$session->get('id');
$db->select('subject_tbl.subject,mark_tbl.mark');
$db->from('subject_tbl');
$db->join('mark_tbl', 'mark_tbl.sub_id = subject_tbl.sub_id');
$db->where('mark_tbl.id', $id);
$query = $db->get();
return $query->result();
}
It returns the error:
Call to undefined method CodeIgniter\Database\MySQLi\Connection::select()
Controller:
public function s_mark()
{
$session=\Config\Services::session();
if($session->has('id'))
{
$data['val']=$this->obj->join();
return view('mark_s',$data);
}
}
CodePudding user response:
I reviewed your source code. have you configured DB settings in .env file??
CodePudding user response:
In Controller file do some changes
public function __construct()
{
parent::__construct();
$this->joinModel = model('ModelNameHere');
}
public function s_mark()
{
$session=\Config\Services::session();
if($session->has('id'))
{
$data['val']=$this->joinModel->join();
return view('mark_s',$data);
}
}