Posts: 4
Threads: 2
Joined: Nov 2019
Reputation:
0
11-27-2019, 02:27 PM
(This post was last modified: 11-27-2019, 06:15 PM by tspowell001.)
I'm new to CI, and I'm working through the CI4 tutorial. I'm at the end of the news section, and the three entries I put in the database are not showing up in the view. I see the output for no entries in the database.
How do I check the connection to the database to make sure there are no issues with it? I pulled up PHPMyAdmin to look at the table, and it has the three entries I entered into it.
Thank you.
Posts: 4,367
Threads: 101
Joined: Oct 2014
Reputation:
146
Did you configure ./app/Config/Database.php to setup you database server?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Posts: 11
Threads: 3
Joined: Feb 2017
Reputation:
0
11-30-2019, 03:41 AM
(This post was last modified: 11-30-2019, 03:42 AM by ProfessionalCoder.)
<?php namespace App\Models;
use CodeIgniter\Model;
class Blabla extends Model{
public function exfunc(){
$db = \Config\Database::connect();
$query = $db->query('SELECT blabla FROM blabla where blabla ');
$results = $query->getResultArray();
return $results;
}
}
A practise way for use database model in CI4.
Sercan YANBULOGLU
SEO links REDACTED, per forum policy
Posts: 4,367
Threads: 101
Joined: Oct 2014
Reputation:
146
@ProfessionalCoder,
CodeIgniter 4 Model already has the automatic database connection.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )