3 class ezSQL_pdo_YOURLS extends ezSQL_pdo {
6 * Constructor - Overwrite original to use MySQL instead of SQLite
10 function ezSQL_pdo_YOURLS( $dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $encoding='' ) {
11 $this->dbuser = $dbuser;
12 $this->dbpassword = $dbpassword;
13 $this->dbname = $dbname;
14 $this->dbhost = $dbhost;
15 $this->encoding = $encoding;
16 $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname ;
19 // Turn on track errors
20 ini_set('track_errors',1);
22 $this->connect( $dsn, $dbuser, $dbpassword );
28 * Connect to MySQL server. Override original function to allow empty passwords
32 function connect( $dsn='', $user='', $password='', $ssl=array() ) {
34 global $ezsql_pdo_str; $return_val = false;
36 // Must have a server/db and a user
37 if ( ! $dsn || ! $user )
39 $this->register_error( $ezsql_pdo_str[1].' in '.__FILE__.' on line '.__LINE__ );
40 $this->show_errors ? trigger_error($ezsql_pdo_str[1],E_USER_WARNING) : null;
43 // Establish PDO connection
48 $this->dbh = new PDO($dsn, $user, $password, $ssl);
52 $this->dbh = new PDO($dsn, $user, $password);
57 catch (PDOException $e)
59 $this->register_error($e->getMessage());
60 $this->show_errors ? trigger_error($e->getMessage(),E_USER_WARNING) : null;
67 * Return MySQL server version
71 function mysql_version() {
72 return ( $this->dbh->getAttribute(PDO::ATTR_SERVER_VERSION) );
78 * Added to the original function: logging of all queries
82 function query( $query ) {
84 // Keep history of all queries
85 $this->all_queries .= $query.'<br />';
88 return parent::query( $query );
94 * Actually not needed for PDO it seems, the function is there only for consistency with
100 function disconnect() {