When we use a PHP application with Firebird database, we use the ibase_connect()
methods to open the connection to the database and ibase_close()
to close this connection. If the connection is opened and not closed using the last command, when the SQL command is finished the connection is terminated.
And the databases have different performances when opening the connection to the database, according to what I was told Firebird is one of the databases that the connection takes to open, so I would like to propose a solution for this in our projects.
Can it be saved in session and is it a way that can be considered? Example:
Database.php :
<?php
session_start();
function OpenConnection(){
if (empty($_SESSION['connection'])){
$host = 'localhost:/path/to/your.gdb';
$dbh = ibase_connect($host, $username, $password);
$_SESSION['connection'] = $dbh;
}
}
?>
File1.php :
<?php
include_once('Database.php');
OpenConnection();
$conn = $_SESSION['connection'];
// Resto das operações
?>
Questions :