Welcome Guest, Not a member yet? Register   Sign In
CI4 Tutorial Database Question
#1

(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.
Reply
#2

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 )
Reply
#3

(11-27-2019, 06:55 PM)InsiteFX Wrote: Did you configure ./app/Config/Database.php to setup you database server?

I did.  I finally discovered my mistake.  A class wasn't coded correctly.  Thanks.
Reply
#4

(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
Reply
#5

@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 )
Reply
#6

(11-30-2019, 05:28 AM)InsiteFX Wrote: @ProfessionalCoder,

CodeIgniter 4 Model already has the automatic database connection.


Thx I rewrite  $db to $this->db->query 
Sercan YANBULOGLU
SEO links REDACTED, per forum policy
Reply




Theme © iAndrew 2016 - Forum software by © MyBB