This topic is locked
[SOLVED]

 SAME PROJECT DIFFERENT DATABASE PHPR 8.0

6/5/2015 5:28:04 AM
PHPRunner General questions
D
Domenico Giacchero author

I am trying to build a project that can use a MYSQL Database OR a MSSQL Database. Production server can have ONLY MSSQL or MySQL. NOT BOTH
running the project with:
localhost/mydir/output/login.php?datadb=MS

or

localhost/mydir/output/login.php?datadb=MY
inserting this code in Server Database Connection (called DoubleConn):
if ($_GET["datadb"]=='MS'){

$host="PC-DOM\\SQLEXPRESS";

$dbname="dbaseone";

$options="SSPI";

$ODBCString = "Provider=SQLNCLI10;Server=PC-DOM\\SQLEXPRESS;Database=dbaseone;Integrated Security=SSPI";

}else{

$host="localhost";

$user="root";

$pwd="";

$port="";

$sys_dbname="dbaseone";

}
the procedure SHOULD select one db or the other, but it is working only with datadb=MY (with datadb=MS I have this error:

Fatal error: php_network_getaddresses: getaddrinfo failed: Host sconosciuto. in C:\webapp\dbmail\output\connections\MySQLiConnection.php on line 84
If I build the project with ONLY MySql Connection or ONLY MSSQL Connection everything it is working fine (Single Connections are OK).
Any Idea?

Thank you to everybody .....

Domenico

Sergey Kornilov admin 6/5/2015

You cannot make the same project switch between SQL Server and MySQL on the fly. Everything in the project is tied to the database type i.e. all database functions, SQL query wrappers (field name vs [field name]) etc.

7542 7/4/2015

Hi
I I did this in PHPRunner 6.2, assume it would still work built in later versions.
Basically I created a button to change the db via session (after login). So my button would say $_SESSION["db"] = "db2";, $_SESSION["db_pass"] = "pass2"; On the login page I also provided a drop down menu to change the db connection (click on this link to change)
In output, edit server connections I created a file with this info
$host="localhost";

$user="XXXXX";

$pwd="XXXX";

$port="";

$sys_dbname="XXX";
if ($_SESSION["dbname"])

$sys_dbname = $_SESSION["dbname"];
if ($_SESSION["dbuser"])

$user = $_SESSION["dbuser"];