Class for storing objects in an external DB cluster
authorJens Frank <jeluf@users.mediawiki.org>
Sat, 21 May 2005 10:15:39 +0000 (10:15 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sat, 21 May 2005 10:15:39 +0000 (10:15 +0000)
includes/ExternalStoreDB.php [new file with mode: 0644]

diff --git a/includes/ExternalStoreDB.php b/includes/ExternalStoreDB.php
new file mode 100644 (file)
index 0000000..de4d3cc
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * 
+ * @package MediaWiki
+ *
+ * DB accessable external objects
+ *
+ */
+require_once( 'LoadBalancer.php' ); 
+
+
+
+class ExternalStoreDB {
+       /* Fetch data from given URL */
+       function fetchFromURL($url) {
+               global $wgExternalServers;
+               #
+               # URLs have the form db://cluster/id, e.g.
+               # mysql://cluster1/3298247
+               #
+               $path = explode( '/', $url );
+               $cluster  = $path[2];
+               $id       = $path[3];
+
+               $lb = LoadBalancer::NewFromParams( $wgExternalServers[$cluster] );
+               $db = $lb->getConnection( DB_SLAVE );
+
+               $ret = $db->selectField( 'text', 'text_text', array( 'text_id' => $id ) ); 
+               
+               return $ret;
+       }
+
+       /* XXX: may require other methods, for store, delete, 
+        * whatever, for initial ext storage  
+        */
+}
+?>