According to http://drupal.org/node/125105#comment-229460, it sounds a good idea if we are able to replace our database connection string as array format. Moreover, I would like to point out the handling of eGroupWare (http://www.egroupware.org/) as example (within /header.inc.php):
/* eGroupWare domain-specific db settings */
$GLOBALS['egw_domain']['example.com'] = array(
'db_host' => 'localhost',
'db_port' => '3306',
'db_name' => 'egroupware',
'db_user' => 'egroupware',
'db_pass' => 'passwd',
// Look at the README file
'db_type' => 'mysql',
// This will limit who is allowed to make configuration modifications
'config_user' => 'root',
'config_passwd' => '76a2173be6393254e72ffa4d6df1030a'
);
Not too complicated, isn't it? Maybe we should give a some love to this issue, so let it ship with D6?
Comments
Comment #1
Crell commentedToo late for D6. Maybe in D7.
Comment #2
hswong3i commentedYup, seems it should belong to D7... BTW, the open of drupal-7.x-dev should not too far from today, I will come back and give some love to this issue. The idea sounds pretty :)
Comment #3
kbahey commentedI support this because I suggested this in the past, before we had an installer. The $db_url = 'mysql://blah:blah@blah/blah' was too cryptic and painful to edit by hand.
So breaking these things in their discrete component would help lessen errors.
Now that we have an installer, this point is not as important.
However, not having to parse the file, and having the variables already accessible to any part of the code that needs it can be a good thing.
I think it should simply be:
We can differ on the names of the array keys, but there is no need to overcomplicate it with extra stuff
Comment #4
Anonymous (not verified) commentedSubscribing.
I'm not sure how I feel about this. I happen to like the one string format and setting the GLOBALS array in the settings file seems a bit wrong to me. Parsing the string only happens once so there isn't really a savings performance wise.
Comment #5
Crell commentedThere's no need to explicitly call $GLOBAL. Currently conf_init() declares $db_url global, then includes the settings.php file, so it gets stuck into the global namespace that way. Now granted, globals are always the wrong answer that's beside the point for now. :-)
I also favor splitting up the connection string format, actually. It does simplify the code involved, and eliminates the need to use URL escape characters for wacky characters in passwords (which some of my clients always insist on using, just to be annoying).
Comment #6
hswong3i commentedWhen I am working with pdo_mysql, I try to create install.pdo_mysql.inc (just as like as install.mysqli.inc), update install.inc with new option, and start the installation. But a critical error is occurred:
pdo_mysql://...syntax is not allowed by parse_url and so connection handling gone mad!I think this should be a critical issue :(
Comment #7
Crell commentedhswong: I ran into the same issue in my earlier PDO attempt. My solution at the time was just to use pdomysql instead of pdo_mysql. Of course, for D7 the solution is to assume that mysql means PDO-MySQL, pgsql means PDO-PostgreSQL, etc.
That said, no, it's not critical.
Comment #8
Anonymous (not verified) commentedI sure hope that if that happens mysql, et alia will still mean mysql when pdo isn't available.
Comment #9
Crell commentedSince Drupal 7 assumes PHP 5.2, assuming PDO is a given because it's part of the stock compile of PHP 5.1+.
Basically, we can't improve our database layer as long as we are supporting ext/mysql, which is the weakest database driver for PHP.
Comment #10
hswong3i commentedA simple patch via D6 CVS HEAD, which should able to help pdo_mysql/pdo_pgsql development will minimum effort. The idea is very simple: since "schema" part of parse_url() don't allow any special characters (e.g. "_"), we can store the database type within "fragment" part which don't have any limitation. Just place a dummy string "database" within "schema" part so parse_url() can function correctly.
I test this patch by copy existing database.mysqli.inc/install.mysqli.inc as database.pdo_mysql.inc/install.pdo_mysql.inc, hack drupal_detect_database_types() for this new database type, and start installation. All procedures are functioning and successful.
Comment #11
Crell commentedThat is a horribly ugly syntax, and is not, in fact, an array. See pdo.php in my sandbox. We don't need to make the connection string backwards for PDO. However, getting rid of the url format entirely and using a real array is probably a good idea for D7, but not yet.
Comment #12
hswong3i commentedThe truth is I am not trying to work out a "perfect version" right now, but a functional version. According to the changed in #10, my personal research project Siren is now able to support pdo_mysql and pdo_pgsql without critical problem caused by the limitation of existing connection string syntax. On the other hand, surly we can foresee this syntax is also suitable for ibm_db2 :)
Anyway, I am now focusing if LDAP user backend would be a solution for our slow account/permission SQL query. This is just something similar as case of eGroupware: store user account and group in LDAP, and other configuration in SQL. In this case, we may need to have 2 connection settings, and the connection setting for LDAP may not suitable to handle with URL syntax, so array format maybe a MUST. Fine, all of this are still my brainstorming ;-p
(This is part of my personal research project Siren's issue.)
Comment #13
Crell commentedThe new DB layer has an array-based format.
Comment #14
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.