diff --git a/class-mysql.php b/class-mysql.php deleted file mode 100644 index c25c183..0000000 --- a/class-mysql.php +++ /dev/null @@ -1,115 +0,0 @@ - PDO::ERRMODE_EXCEPTION) - * The attribute options are then set in a foreach($attr as $k=>$v){$db->setAttribute($k, $v)} loop - */ - $driver_options = yourls_apply_filter( 'db_connect_driver_option', [] ); // driver options as key-value pairs - $attributes = yourls_apply_filter( 'db_connect_attributes', [] ); // attributes as key-value pairs - - $ydb = new \YOURLS\Database\YDB( $dsn, $user, $pass, $driver_options, $attributes ); - $ydb->init(); - - // Past this point, we're connected - yourls_debug_log( sprintf( 'Connected to database %s on %s ', $dbname, $dbhost ) ); - - yourls_debug_mode( YOURLS_DEBUG ); - - return $ydb; -} - -/** - * Helper function : return instance of the DB - * - * Instead of: - * global $ydb; - * $ydb->do_stuff() - * Prefer : - * yourls_get_db()->do_stuff() - * - * @since 1.7.10 - * @return \YOURLS\Database\YDB - */ -function yourls_get_db() { - // Allow plugins to short-circuit the whole function - $pre = yourls_apply_filter( 'shunt_get_db', false ); - if ( false !== $pre ) { - return $pre; - } - - global $ydb; - $ydb = ( isset( $ydb ) ) ? $ydb : yourls_db_connect(); - return yourls_apply_filter('get_db', $ydb); -} - -/** - * Helper function : set instance of DB, or unset it - * - * Instead of: - * global $ydb; - * $ydb = stuff - * Prefer : - * yourls_set_db( stuff ) - * (This is mostly used in the test suite) - * - * @since 1.7.10 - * @param mixed $db Either a \YOURLS\Database\YDB instance, or anything. If null, the function will unset $ydb - * @return void - */ -function yourls_set_db($db) { - global $ydb; - - if (is_null($db)) { - unset($ydb); - } else { - $ydb = $db; - } -}