Update:
I'm successfully able to re-connect to the db, however, not sure if this is a bug or not. But after I re-connect, I'm unable to run $modx->addPackage
These are my findings.
First, the package I'm adding adds support for a custom table, all of which I followed from here:
http://bobsguides.com/custom-db-tables.html
Now, this runs just fine, until the DB connection is lost. What I'm finding is that after I re-initialize modx, I can add the package, but a few details are missing. I'm just stumped here.
Here's just a short snipped from the package:
This is when the package has been added, and is functioning correctly.
fieldNames] =>
[_class] => Dataresults
[_package] => twitter
[_alias] => Dataresults
[_pk] => id
[_pktype] =>
[_table] => `twitter_dataresults`
[_tableMeta] =>
This is when I re-add the package after loosing the db.
[fieldNames] =>
[_class] => Dataresults
[_package] =>
[_alias] => Dataresults
[_pk] => id
[_pktype] =>
[_table] =>
[_tableMeta] =>
Now, if I keep comparing the printed array, [_fieldMeta] is empty as well.
Basically, here is the code I'm using for when the DB connection is lost, and I attempt to re-connect:
public static function reconnect() {
self::$modx = new modX();
self::$modx->initialize('mgr');
// Add the Twitter package
self::$twitterStatsObject = self::$modx->addPackage('twitter',self::$twitter_package . 'model/','twitter_');
if (!self::$twitterStatsObject) {
echo 'Failed to add Twitter Stats Package' . "\n";
exit();
}
}
The above code works well, except for the package. Am I missing something here? Also, the add package code is exactly the same in the connect() method.
[ed. note: whnunlife last edited this post 13 years, 7 months ago.]