Fork me on GitHub
Current releases are 2.1.3 (9 Sept 2014) and 2.0.18.13 (5 Aug 2014)

Ready for 2.1? Find out if your favorite plugins are compatible. The 2.0 branch will no longer receive updates after Dec 2014.

For Those Who Don't Have PDO

ShadowdareShadowdare π Moderator
edited December 2010 in Vanilla 2.0 Help
A question that usually would appear would be about an error relating to PDO shows up when you visit your freshly uploaded Vanilla 2.0.15 folder. It's obviously not a bug but I don't know where else to post this, but I originally had the question of "why am I getting an error about PDO?"

I wanted to help out by showing a small workaround. This happens because the PDO extension doesn't exist on the servers of your host. If your host, for some weird reason, denies enabling PDO, then there are workarounds available online. I managed to get PHPPDO to do it.

The error looks like this:
Class 'PDO' not found in /vanilla/conf/config-defaults.php

I downloaded PHPPDO and created a folder called "phppdo" in the root of my Vanilla folder. I then opened /vanilla/library/core/class.router.php and added these lines of code to the top:
function db_connect($dsn, $username = '', $password = '', $driver_options = array(), $path = './phppdo')
{
$driver = strtolower(trim(substr($dsn, 0, strpos($dsn, ':'))));

if($driver && class_exists('PDO') && extension_loaded('pdo_' . $driver))
{
$class = 'PDO';
}
else
{
require_once($path . '/phppdo.php');
$class = 'PHPPDO';
}

return new $class($dsn, $username, $password, $driver_options);
}

try
{
$db = db_connect('mysql:dbname=', 'dbuser', 'dbpass', array(), $_SERVER['DOCUMENT_ROOT'].'/vanilla/phppdo');
} catch(PDOException $e)
{
die($e->getMessage());
}


For the try statement, I added in my database info after each equals sign and the variables in $db. I'm not sure how to call the variables for $DatabaseName, $DatabaseUser, $DatabasePassword yet. If anyone knows how, please let me know.

After saving that file, I received another error like this one:
Cannot instantiate abstract class PDO in /vanilla/applications/dashboard/controllers/class.setupcontroller.php on line 120

So I opened that file up and went down to line 120 and changed it up:
Find:
$Connection = new PDO
Change that to:
$Connection = new PHPPDO

Then I received the same error for /vanilla/library/database/class.database.php. The same fix applies here on line 56:
Change:
$this->_Connection = new PDO
To:
$this->_Connection = new PHPPDO

Now you can run Vanilla without PDO installed on your server.

Comments

Sign In or Register to comment.