Closed fre2mansur closed 2 years ago
db_connect()
does not connect to the database yet.
What do you want to do?
To test the custom connection before do the forge operations
I am trying to this by CI way,
Create connection $conn = new mysqli($servername, $username, $password);
// Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully";
db_connect()
does not connect to the database yet. What do you want to do?
What do you mean by it does not connected to the database yet?
What do you mean by it does not connected to the database yet?
db_connect()
just creates CI's DB connection object.
The code in your usage is not executed yet in the db_connect()
.
// Create connection
$conn = new mysqli($servername, $username, $password);
You don't have a failover set for your DB connections, so upon db_connect()
your connection won't start yet.
Try either (1) setting failover connections, or (2) db_connect($custom)->connect();
PHP Version
8.1
CodeIgniter4 Version
4.2.4
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
mysql
What happened?
Connection id is always empty whether is the connection is correct or wrong.
Steps to Reproduce
Expected Output
The connection id should be valid for the connected connection
['code' => string|int, 'message' => string
intval(code) === 0
means "no error".Anything else?