Singleton style function for connection to PDO

Uses static function variable to have only one instance of connection handler. Read more.

php
fork add to bundle source
function mysql_pdo_connect() { static $pdo; if ( !$pdo ) { $pdo = new PDO('mysql:host=127.0.0.1;dbname=db', 'user', 'pwd'); } return $pdo; }

usage

load_function('mysql_pdo_connect'); $statement = mysql_pdo_connect()->query('SELECT "hello"'); $row = $statement->fetch(); print_r($row); // ...
← how to use this in app?
create log ...inout