Re: phpWeather Feature Request
Brought to you by:
iridium
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 |