I have done something similar on my projects, but this is a
much more
elegant soution than mine. Thanks for sharing.
-jmb
bimal_kcmit wrote:
> Do not change your connection strings! Tweak your code
instead.
>
> Hi Everybody,
> I have discovered a good solution for all newbies!
> I don't think I am new to PHP technology, so started
> sharing my scripts for you!
>
> A lot of time, you might feel a trouble regarding the
> mysql's connection strings specially while you are
> working a development copy of the database and with
> a production copy. You might have to face a challenge
> of editing the files each time you change your
connections.
>
> Just look at this script below, how simply I solved the
case?
> Simple idea, hyh? Just load the configuration according
> to the server name the php script is running on.
>
> Glad at this?
> Please leve me a good comment if this
helped you.
>
> <?php
> $dbinfo=array();
>
> $dbinfo['localhost']['host']='localhost';
> $dbinfo['localhost']['dbuser']='root';
> $dbinfo['localhost']['dbpassword']='';
> $dbinfo['localhost']['database']='_mac2';
>
> $dbinfo['www.myserver.com']['host']='localhost';
> $dbinfo['www.myserver.com']['dbuser']='mactim';
> $dbinfo['www.myserver.com']['dbpassword']='26456447';
> $dbinfo['www.myserver.com']['database']='_maals';
>
> $index = $_SERVER['SERVER_NAME'];
>
> $dbcon= mysql_connect(
> $dbinfo[$index]['host'],
> $dbinfo[$index]['dbuser'],
> $dbinfo[$index]['dbpassword']
> ) or die("could not connect to database.");
>
> mysql_select_db(
> $dbinfo[$index]['database'],
> $dbcon
> ) or die("Database can not be selected -
".mysql_error());
>
> ?>
>
>
PHP Data object relational mapping generator
http://www.metastorage.ne
t/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://gro
ups.yahoo.com/group/php-objects/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http:/
/groups.yahoo.com/group/php-objects/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:php-objects-digest@yahoogroups.com
mailto:php-objects-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|