connecting to mysql database(either remote or local) from ph
Posted: Fri Apr 04, 2008 9:16 am
Hello people
does anyone have any idea to test a php application using database first in local and afterwards in the remote server?
What i mean is, does anyone know how to do it without having to change the code used to get the connection to the database.
My code to connect to the database looks like this:
//$miconexion->conectar("jorlal8_nueva", "mysql4.freehostia.com", "jorlal8_nueva", "******");//remote
$miconexion->conectar("jorlal8_nueva", "localhost", "jorlal8_nueva", "******");//local
Each time i want to test on remote I have to comment the line to connect to mysql in localhost so that I can be testing at the remote mysql database which in my case is in freehostia. But if i want to test later at localhost i'll have to change the code again.
Does anybody knows how to do this?
Someone told me that he used application variables to know whether the code was running local or not. Besides he told me another posibility which was using xml tags to distinguish between debugging and normal run of the application. Nevertheless, I am still very lost.
Please I would appreciate any help about this.
Thank you
does anyone have any idea to test a php application using database first in local and afterwards in the remote server?
What i mean is, does anyone know how to do it without having to change the code used to get the connection to the database.
My code to connect to the database looks like this:
//$miconexion->conectar("jorlal8_nueva", "mysql4.freehostia.com", "jorlal8_nueva", "******");//remote
$miconexion->conectar("jorlal8_nueva", "localhost", "jorlal8_nueva", "******");//local
Each time i want to test on remote I have to comment the line to connect to mysql in localhost so that I can be testing at the remote mysql database which in my case is in freehostia. But if i want to test later at localhost i'll have to change the code again.
Does anybody knows how to do this?
Someone told me that he used application variables to know whether the code was running local or not. Besides he told me another posibility which was using xml tags to distinguish between debugging and normal run of the application. Nevertheless, I am still very lost.
Please I would appreciate any help about this.
Thank you