class Toolbox_Import extends WP_Importer
{
private $_dbh;
- function __construct(){}
+ function __construct()
+ {
+ }
+
+ function connect()
+ {
+ // read optios for the import and if they aren't set then give a warning.
+ $options = get_option(GLM_WP_IMPORT_SETTINGS);
+ // try making a postgres connection to the database
+ $connString = 'dbname=' . $options['db_name'];
+ $connString .= ' host=' . $options['db_host'];
+ $connString .= ' user=' . $options['db_user'];
+ $driverOptions = array(
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
+ );
+ $this->_dbh = new PDO('pgsql:'.$connString, null, null, $driverOptions);
+ $this->_dbh->setAttribute(
+ PDO::ATTR_ERRMODE,
+ PDO::ERRMODE_EXCEPTION
+ );
+ }
function header()
{
function greet()
{
echo '<h2>Hello there person!</h2>';
- // read optios for the import and if they aren't set then give a warning.
- $options = get_option(GLM_WP_IMPORT_SETTINGS);
- echo '<pre>'.print_r($options, true).'</pre>';
- // try making a postgres connection to the database
- $connectionString = 'dbname=' . $options['db_name'];
- $connectionString .= ' host=' . $options['db_host'];
- $connectionString .= ' user=' . $options['db_user'];
- $driverOptions = array(
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
- );
- $this->_dbh = new PDO('pgsql:'.$connectionString, null, null, $driverOptions);
- $this->_dbh->setAttribute(
- PDO::ATTR_ERRMODE,
- PDO::ERRMODE_EXCEPTION
- );
- echo '<pre>'.print_r($this->_dbh, true).'</pre>';
+ $this->connect();
$sql = "SELECT * FROM toolbox.pages";
$data = $this->_dbh->query($sql)->fetchAll();
- echo '<pre>'.print_r($data, true).'</pre>';
+ printf('<p>Found %d Pages</p>', count($data));
}
function dispatch()