Hello,
I'm a newbie here.
I use CodeIgniter for all my development in php since several years. I never posted on this forum but I read it often .
Today I create a account because I face a problem I don't understand. I don' know if it's my configuration or a bug. I thought it would be better to post that here before create a report issue on github.
I cannot connect to database starting from codeigniter v4.2.0. It works with codeigniter v4.1.9 on the same computer and with the same code.
The error mesage is : "Error connecting to the database: CodeIgniter\Database\Exceptions\DatabaseException: Fournisseur TCP : Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée."
The database do not accept the connection.
I think the database configuration is ok because it works on v4.1.9.
I use php 7.4.5, apache and SQL Express 2019.
Below the database configuration in the ".env" file
Code:
database.default.hostname = localhost\SQLEXPRESS
database.default.database = Diag
database.default.username = Gmp
database.default.password = *******
database.default.DBDriver = sqlsrv
And here the model
PHP Code:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UtilisateursModel extends Model
{
protected $table = 'Utilisateurs';
protected $primaryKey = 'Id';
protected $useAutoIncrement = true;
protected $allowedFields = [
'Nom',
'Prenom',
'Groupe',
'NumBadge',
'EstActif',
'DateCreation',
'DerniereConnexion',
'EstConnecte',
'Poste',
'DerniereDeconnexion',
];
}
And there is nothing special in the controller
PHP Code:
<?php
namespace App\Controllers;
use App\Models\UtilisateursModel;
class Home extends BaseController
{
public function index()
{
$model = New UtilisateursModel();
var_dump($model->findAll());
}
}
Do you have the same issue with SqlServer?
Thanks