PHP code example of lfphp / pdodsn

1. Go to this page and download the library: Download lfphp/pdodsn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lfphp / pdodsn example snippets



use LFPhp\PDODSN\Database\MySQL;
use LFPhp\PDODSN\DSN;

$dsn_string = 'mysql:host=localhost;dbname=testdb;charset=utf8mb4';
$dsn = DSN::resolveString($dsn_string);
if($dsn instanceof MySQL){
	var_dump($dsn->port);
	die;
}

    
use LFPhp\PDODSN\Database\MySQL;

$mysql_dsn = new MySQL();
$mysql_dsn->host = 'localhost';
$mysql_dsn->database = 'user';
echo $mysql_dsn->__toString();