]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - includes/ezSQL/ez_sql_pdo_yourls.php
Merge branch 'master' of https://github.com/danielnr/YOURLS into danielnr-master
[Github/YOURLS.git] / includes / ezSQL / ez_sql_pdo_yourls.php
1 <?php
2
3 class ezSQL_pdo_YOURLS extends ezSQL_pdo {
4
5         /**
6         * Constructor - Overwrite original to use MySQL and handle custom port
7         * 
8         * @since 1.7
9         */
10         function ezSQL_pdo_YOURLS( $dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $encoding='' ) {
11                 $this->dbuser = $dbuser;
12                 $this->dbpassword = $dbpassword;
13                 $this->dbname = $dbname;
14                 // Get custom port if any
15                 if ( false !== strpos( $dbhost, ':' ) ) {
16                         list( $dbhost, $dbport ) = explode( ':', $dbhost );
17                         $dbhost = sprintf( '%1$s;port=%2$d', $dbhost, $dbport );
18                 }
19                 $this->dbhost = $dbhost;
20                 $this->encoding = $encoding;
21                 $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname ;
22                 $this->dsn = $dsn;
23                 
24                 // Turn on track errors 
25                 ini_set('track_errors',1);
26                 
27                 $this->connect( $dsn, $dbuser, $dbpassword );
28                 
29         }
30
31         /**
32          * Return MySQL server version
33          *
34          * @since 1.7
35          */
36         function mysql_version() {
37                 return ( $this->dbh->getAttribute(PDO::ATTR_SERVER_VERSION) );
38         }
39         
40         /**
41          * Perform mySQL query
42          *
43          * Added to the original function: logging of all queries
44          *
45          * @since 1.7
46          */
47         function query( $query ) {
48         
49                 // Keep history of all queries
50                 $this->debug_log[] = $query;
51
52                 // Original function
53                 return parent::query( $query );
54         }
55
56         /**
57         * Disconnect
58         * 
59         * Actually not needed for PDO it seems, the function is there only for consistency with
60         * other classes
61         *
62         * @since 1.7
63         */
64         function disconnect() {
65                 // bleh
66         }       
67         
68
69 }
70