Permalink
Browse files

New post on drupal 6 and akiban.

  • Loading branch information...
posulliv committed May 18, 2012
1 parent c6d62df commit a9f3157a7353167daee93e318c77a0199546cc8d
Showing with 67 additions and 0 deletions.
  1. +67 −0 _posts/akiban/2012-05-18-drupal-6-akiban.markdown
@@ -0,0 +1,67 @@
+---
+title: Using Akiban Server with Drupal 6
+layout: post
+---
+
+In my [previous post][post_link], I mentioned I'm working on a database driver
+for Drupal 7 for the Akiban Server. However, we have some clients who use
+Drupal 6 so I wanted to talk about how we work with those clients in this post.
+
+Drupal 6 does not have a database abstraction layer so it is not as easy
+to integrate Akiban in this case. With Drupal 6, we do not attempt to run all
+of Drupal on Akiban. What we have done with our existing customers who use
+Drupal 6 is to send certain problem queries to Akiban (running in our MySQL
+replication configuration) and everything else to MySQL. The Akiban Server
+speaks the PostgreSQL protocol as I discussed [before][deploy_post]. Hence,
+for Drupal 6, we use the PostgreSQL database driver to talk to Akiban.
+
+Since Drupal 6 does not support speaking to multiple different database
+backends at the same time, we apply a [patch][gen_patch] to get started.
+Basically, this patch allows connections to be open to both an existing MySQL
+server and the Akiban Server at the same time. It could be used to do the same
+with a PostgreSQL database as well.
+
+Once that patch is applied, to send a query to Akiban, the active database
+connection is set to Akiban and a query is fired off for the Akiban Server to
+execute. The following code snippet shows an example.
+
+{% highlight php %}
+if ($this->use_akiban) {
+ db_set_active('akiban');
+ $result = db_query_range($query,
+ $args,
+ $offset,
+ $this->pager['items_per_page']);
+}
+db_set_active('default')
+if (! $result) { /* if Akiban failed go to regular MySQL */
+ $result = db_query_range($query,
+ $args,
+ $offset,
+ $this->pager['items_per_page']);
+}
+{% endhighlight %}
+
+As can be seen in the code above, its also possible to detect if the query
+failed against Akiban and re-issue it against MySQL.
+
+When deployed in this configuration, connection details for the Akiban Server
+is specified in the `settings.php` file for a Drupal site.
+
+{% highlight php %}
+$db_url = array(
+ "default" => "mysql://drupal:drupal@mysql_hostname/drupal_schema",
+ "akiban" => "pgsql://drupal:drupal@akiban_hostname:15432/drupal_schema"
+);
+{% endhighlight %}
+
+We've also done some work with clients where we have made patches to the Views
+module for Drupal. These patches allow a client to send the queries generated by
+a specific view to an Akiban Server.
+
+Taken together, this makes it quite easy for us to work with Drupal 6 and send
+problematic queries to Akiban.
+
+[post_link]: http://posulliv.github.com/2012/05/14/drupal-akiban.html
+[gen_patch]: https://gist.github.com/2710166
+[deploy_post]: http://www.akiban.com/blog/2011/08/29/typical-akiban-deployment

0 comments on commit a9f3157

Please sign in to comment.