3 class ezSQL_pdo_YOURLS extends ezSQL_pdo {
6 * Constructor - Overwrite original to use MySQL and handle custom port
10 function __construct( $dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $encoding='' ) {
11 $this->show_errors = defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG; // comply to YOURLS debug mode
12 $this->dbuser = $dbuser;
13 $this->dbpassword = $dbpassword;
14 $this->dbname = $dbname;
15 // Get custom port if any
16 if ( false !== strpos( $dbhost, ':' ) ) {
17 list( $dbhost, $dbport ) = explode( ':', $dbhost );
18 $dbhost = sprintf( '%1$s;port=%2$d', $dbhost, $dbport );
20 $this->dbhost = $dbhost;
21 $this->encoding = $encoding;
22 $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname ;
25 // Turn on track errors
26 ini_set('track_errors',1);
28 $this->connect( $dsn, $dbuser, $dbpassword );
33 * Return MySQL server version
37 function mysql_version() {
38 return ( $this->dbh->getAttribute(PDO::ATTR_SERVER_VERSION) );
44 * Added to the original function: logging of all queries
48 function query( $query ) {
50 // Keep history of all queries
51 $this->debug_log[] = $query;
54 return parent::query( $query );
60 * Actually not needed for PDO it seems, the function is there only for consistency with
65 function disconnect() {