Thread: phpWeather Feature Request
Brought to you by:
iridium
From: Phil P. <phi...@sw...> - 2004-02-08 04:17:11
|
From what I can tell, once you configure phpWeather to talk to MySQL, it will make its own connection to the database. I've added data from phpWeather to my webpage, and it's all working fine. However in the process of generating my page, I already initiate a connection to the database. Is there any *really simple* way I can pass these details to phpWeather for it to use? Assuming, of course, that phpWeather won't blithely go and close the pre-existing connection once it's done with it. Thanks, Phil P |
From: Max H. <ma...@fl...> - 2004-02-08 23:07:23
|
Hi, > From what I can tell, once you configure phpWeather to talk to MySQL, > it will make its own connection to the database. yes > However in the process of generating my page, I already initiate a > connection to the database. > > Is there any *really simple* way I can pass these details to phpWeather > for it to use? Assuming, of course, that phpWeather won't blithely go > and close the pre-existing connection once it's done with it. If you're using pconnect() - permenent connections to the database, it doesn't matter - it'll just use an existing connection if one is open. Cheers, Max |
From: Martin G. <gim...@gi...> - 2004-02-08 23:11:52
|
Phil Pierotti <phi...@sw...> writes: Hi Phil, it's nice with all your feedback! > From what I can tell, once you configure phpWeather to talk to MySQL, > it will make its own connection to the database. Yes, it calls mysql_connect or mysql_pconnect in the connect method in file db/pw_db_mysql.php. > However in the process of generating my page, I already initiate a > connection to the database. > > Is there any *really simple* way I can pass these details to > phpWeather for it to use? Assuming, of course, that phpWeather won't > blithely go and close the pre-existing connection once it's done > with it. If you're worried about having two open links to MySQL at the same time, then there's no problem, the PHP manual says: If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. If you're annoyed about having your password spread across several files, then the easiest solution is to make your defaults.php file reference the password as a variable: /* db_password */ $this->properties['db_password'] = $GLOBALS['password']; and then make sure that $password is in the global scope. And finally, there is a disconnect method in all the database backends, but it isn't used at the moment, and I don't think that will change, it's just there for completeness. -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather: Shows the current weather on your webpage and PHP Shell: A telnet-connection (almost :-) in a PHP page. |
From: Martin G. <gim...@gi...> - 2004-02-09 00:57:09
|
Phil Pierotti <phi...@sw...> writes: Hi Phil, it's nice with all your feedback! > From what I can tell, once you configure phpWeather to talk to MySQL, > it will make its own connection to the database. Yes, it calls mysql_connect or mysql_pconnect in the connect method in file db/pw_db_mysql.php. > However in the process of generating my page, I already initiate a > connection to the database. > > Is there any *really simple* way I can pass these details to > phpWeather for it to use? Assuming, of course, that phpWeather won't > blithely go and close the pre-existing connection once it's done > with it. If you're worried about having two open links to MySQL at the same time, then there's no problem, the PHP manual says: If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. If you're annoyed about having your password spread across several files, then the easiest solution is to make your defaults.php file reference the password as a variable: /* db_password */ $this->properties['db_password'] = $GLOBALS['password']; and then make sure that $password is in the global scope. And finally, there is a disconnect method in all the database backends, but it isn't used at the moment, and I don't think that will change, it's just there for completeness. -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather: Shows the current weather on your webpage and PHP Shell: A telnet-connection (almost :-) in a PHP page. |
From: Max H. <ma...@fl...> - 2004-02-09 08:25:58
|
> If you're annoyed about having your password spread across several > files, then the easiest solution is to make your defaults.php file > reference the password as a variable: > > /* db_password */ > $this->properties['db_password'] = $GLOBALS['password']; > > and then make sure that $password is in the global scope. I wouldn't do that unless either i) you are the only user on your server, or ii) PHP is in safe mode. Otherwise, some other user could include() your file, and retrieve your password. Cheers, Max |
From: Max H. <ma...@fl...> - 2004-02-09 09:01:30
|
> If you're annoyed about having your password spread across several > files, then the easiest solution is to make your defaults.php file > reference the password as a variable: > > /* db_password */ > $this->properties['db_password'] = $GLOBALS['password']; > > and then make sure that $password is in the global scope. I wouldn't do that unless either i) you are the only user on your server, or ii) PHP is in safe mode. Otherwise, some other user could include() your file, and retrieve your password. Cheers, Max |
From: Phil P. <phi...@sw...> - 2004-02-09 01:01:49
|
> Yes, it calls mysql_connect or mysql_pconnect in the connect method in > file db/pw_db_mysql.php. Yup! Saw that. >>However in the process of generating my page, I already initiate a >>connection to the database. >> >>Is there any *really simple* way I can pass these details to >>phpWeather for it to use? Assuming, of course, that phpWeather won't >>blithely go and close the pre-existing connection once it's done >>with it. > > > If you're worried about having two open links to MySQL at the same > time, then there's no problem, the PHP manual says: > > If a second call is made to mysql_connect() with the same arguments, > no new link will be established, but instead, the link identifier of > the already opened link will be returned. That's the one! mmm, odd - I'm fairly sure it's the same params (no other db/user/pass is valid) and yet I'm seeing that 1 page refresh shows Connections Counter+2 under MySQL CC. There's only my 'insert a pageview' thingy which assumes an open connection (ie it's opened by the main page script) and then there's my call to phpWeather - nothing else talks to the database. I guess I need to do more hunting. > If you're annoyed about having your password spread across several > files, then the easiest solution is to make your defaults.php file > reference the password as a variable: > > /* db_password */ > $this->properties['db_password'] = $GLOBALS['password']; oooh! Nice suggestion, this is MUCH cleaner - thanks. > and then make sure that $password is in the global scope. > > And finally, there is a disconnect method in all the database > backends, but it isn't used at the moment, and I don't think that will > change, it's just there for completeness. OK good. Thanks, Phil P |