note 128014 added to pdo.construct

From: Date: Tue, 13 Dec 2022 12:26:32 +0000
Subject: note 128014 added to pdo.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-219970@lists.php.net to get a copy of this message
If you override PDO with own class and you want to implement alias from php.ini, you have to get it with get_cfg_var instead of ini_get. <?php class PDO extends \PDO { public function __construct(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null) { //alias if (!str_contains($dsn, ':')) { $dsn = get_cfg_var('pdo.dsn.' . $dsn); if (!$dsn) { throw new PDOException('Argument #1 ($dsn) must be a valid data source name'); } } // your additional logic parent::__construct($dsn, $username, $password, $options); } } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.175 (proxied: 185.155.32.47) ---- Manual Page -- https://php.net/manual/en/pdo.construct.php Edit -- https://main.php.net/note/edit/128014 Del: integrated -- https://main.php.net/note/delete/128014/integrated Del: useless -- https://main.php.net/note/delete/128014/useless Del: bad code -- https://main.php.net/note/delete/128014/bad+code Del: spam -- https://main.php.net/note/delete/128014/spam Del: non-english -- https://main.php.net/note/delete/128014/non-english Del: in docs -- https://main.php.net/note/delete/128014/in+docs Del: other reasons-- https://main.php.net/note/delete/128014 Reject -- https://main.php.net/note/reject/128014 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219970) next »