Welcome Guest, Not a member yet? Register   Sign In
can't create instance of a model class in models from controller class
#7

a model is just a class , after reading namespace primer i simply created another directory within app

i'm starting with keeping things simple ( i'm only playing with CI4 at this stage) using

<?php namespace App\Andy;
use CodeIgniter\Database\ConnectionInterface;

class DoStuff

{
protected $title;
protected $article;



public function index()
{
$db = \Config\Database::connect("default");

$query = $db->query("SELECT * FROM blog");
$row = $query->getRowArray();
return $row['title'].$row['article'];


}



i can retrieve from sqlite database ; i can also insert into database
Reply


Messages In This Thread
RE: can't create instance of a model class in models from controller class - by captain-sensible - 12-09-2019, 07:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB