Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 62762 invoked from network); 9 Jun 2007 07:47:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jun 2007 07:47:43 -0000 Received: (qmail 2499 invoked by uid 500); 9 Jun 2007 07:47:45 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 2237 invoked by uid 500); 9 Jun 2007 07:47:45 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 2228 invoked by uid 99); 9 Jun 2007 07:47:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jun 2007 00:47:45 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [80.229.52.226] (HELO grimnir.webthing.com) (80.229.52.226) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jun 2007 00:47:41 -0700 Received: from grimnir.webthing.com (localhost [127.0.0.1]) by grimnir.webthing.com (Postfix) with ESMTP id 0A0E3214A for ; Sat, 9 Jun 2007 08:47:20 +0100 (BST) Date: Sat, 9 Jun 2007 08:47:19 +0100 From: Nick Kew To: modules-dev@httpd.apache.org Subject: Re: mod vhost sql Message-ID: <20070609084719.5c24b50c@grimnir> In-Reply-To: <466A52ED.6@gmail.com> References: <466A52ED.6@gmail.com> Organization: WebThing X-Mailer: Sylpheed-Claws 2.5.0-rc3 (GTK+ 2.10.6; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Sat, 09 Jun 2007 09:12:45 +0200 Maikel Punie wrote: > hey, > > I'm trying to write a mod_vhost_mysql, but this time one that can get > all the data from the mysql db, and not just the docroot. All what data? Do you mean every apache directive, including those implemented by third-party modules, should work in SQL? If so, take a look at mod_macro, which gives you the crux of the matter: namely a module feeding configuration to other modules. Also, please get MySQL out of your mindset here. You should the Apache DBD framework, so your module supports other database backends automatically. > So basically for every request the ap_hook_translate_name() is called > to handle the function inside my module. Now I'm confused. *what* is the scope of this module? > at the moment for every request thats done the modules does the > following: 1- create a db connection > 2- do the sql query > 3- parse results > 4- close db > 5- return OK > > basically this isn't really nice to handle, creating a db connection > and closing it for every request will create an enormous pressure on > the mysql db server. That's another reason to use mod_dbd. > So now the question, is there a hook (or hooks) that is defined so i > can call it, > 1- just before the server actually starts running (after config > parsing i guess) Yes. > 2- just before the server stops running No. Use a pool cleanup. > this way i could open up the db connection with hook one, and close it > with hook two, this will decrease the load on the db server. That's been a solved problem since mod_perl gave us the architecture now known as LAMP, back in '95 (or was it '96?). In the intervening years we've moved on, and DBD solves two major issues you'll still have if you just make the changes you're asking about here. -- Nick Kew Application Development with Apache - the Apache Modules Book http://www.apachetutor.org/