On Fri, 25 Mar 2011 15:34:00 -0600, Merrill Oveson wrote:
> I use an app_constants.php file in my includes section.
>
> The file contains the database name, database_user,
> database_user_password:
>
> i.e.
> define("DB_HOST", "localhost");
> define("DB_USER", "user");
> define("DB_PASS", "password");
> define("DB_NAME", "mydb_name");
>
> Then I call those variables from my mysql_db class.
>
> If I need to change databases, it's easy to change the data in the
> app_constants file.
>
> I hope this helps. I'm sure I'm not the only one who does this.
>
Oh I do the same thing already, I have a config file that contains
various things that I need to set, but I am specifically talking about
how I connect to MySQL. My MySQL class file calls the config file for
the information needed to connect, but I want to change my connection
method from mysql_(p)connect to PDO. If it's not worth trouble to go
through right now, I'll just not worry about it. But for the sake of
explaining it a little better, this is what I've got in my MySQL class
file right now:
//-----------
include(config.php);
class Mysql {
private $conn;
function __construct() {
$this->link = mysql_pconnect(host,user,pass);
// check connection and handle errors
// if passes, select db after a check it as well
return $this->link;
}
function foo($sql) {
// something really cool
}
}
//-----------
So I want to replace the connection part in my constructor with a PDO
connection. Hope that helps clarify things.
-Brian
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net