PhpLiveDb::__construct

Creates a connection to the database

Sintaxe

namespace ProtocolLive\PhpLiveDb;
use ProtocolLive\PhpLiveDb\Enums\Drivers;

/**

 */
final class PhpLiveDb{
public function __construct(
string $Ip,
string $User,
string $Pwd,
string $Db,
string $Drive = Drivers::MySql,
string $Charset = 'utf8mb4',
int $TimeOut = 5,
string $Prefix = null,
callable $OnRun = null
);
}
Parameters

$Ip - Database address, ip or DNS;

$User - User to authenticate;

$Pwd - Password to authenticate;

$Db - Default database schema;

$Drive - The database used;

$Charset - The character set;

$TimeOut - Maximun seconds to run a query;

$Prefix - Text to be concated with "_" and table name;

$OnRun - A callable function to be executed after a Run;

Dependencies

- PHP >= 8.1;

- One of the PDO PHP extensions;

See more

- PDO construct

Examples

$Db = new PhpLiveDb('localhost', 'root', '', 'mysite', Prefix: 'mydb');