[drupal-devel] [task] Drupal Install System

Daniel Convissor danielc at analysisandsolutions.com
Thu Mar 31 21:20:14 UTC 2005

Hi Adiran:

On Thu, Mar 31, 2005 at 09:43:06PM +0200, Adrian Rossouw wrote:
> The idea would be to create a drupal.install file, which would use the 
> drupal db_query function
> on the schema elements.

What's a "drupal.install file," please?

What I was thinking is this script would gather the sites info, obtain the 
table creation queries from /drupal/database/database.(mysql|pgsql), 
prefix the table names as specified by the sites info, then execute the 

Here's my goal at this point for the script I'm creating: once users have 
set up their /drupal/sites/*/settings.php files, they can execute my 
script by going into the database directory and issuing the following 
command: "php ./create.php".  That would create all of their tables in one 

But if you're thinking of some other approach, what I've written so far is 
very modular so should be able to wrestle up whatever you want.

Here are three of the functions I have so far:

 * Obtains configuration settings specified in all settings.php files.
 * @return
 *   The four dimensional associative array settings for all sites.
 *   The main array's keys is the $db_url.
 *   The sub-array's keys are the site directory names.
 *   The sub-sub-array has two keys: 'default' and 'named'.
 *   'named' is an array with table names for keys and table name prefixes
 *   for values.
 *   'default' is a string that should prefix all other tables.
function get_site_settings() {

 * Grabs the contents of the query script and puts each query into
 * an array element.
 * @param $dbms
 *   The name of the DBMS you are want the queries for ('mysql', 'pgsql').
 * @return
 *   An array with each query in a separate element.
function get_queries_from_file($dbms) {

 * Goes through each element of the queries array, prefixing the table
 * names as needed.
 * @param $queries
 *   The enumerated array containing one query per element.
 * @param $named
 *   The associative array of specific tables to prefix.
 *   Each key is a table name and the value is the prefix for that table.
 * @param $default
 *   The string for prefixing all other tables.
 * @return
 *   The array of queries with the table names prefixed as needed.
function prefix_queries_in_array($queries, $named, $default) {

Now, off the top of my head (I need to leave shortly, so am rushing) what 
I still need to write two functions.

One would gathering all of the queries for a given $db_url.  Part of what 
it would do is eliminate duplicate queries.

Another method would execute all of the queries in an array.


 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409

More information about the drupal-devel mailing list