Multi database connection

Hello everybody,

I use a multi database login to my web application, everything works fine but I need to enter login name and password twice !!!
Thanks
Nac

Here are code detail :

login control_app :

in SQL setting : connection is ‘system’ ( system is a database containing only empty users table)
in ONEXECUTE :

$mdbname=sc_sql_injection(md5($mdbname)); ( $mdbname contain database name )

$arr_conn[‘database’] = trim($mdbname);
$arr_conn[‘persistent’] = “Y”;
$arr_conn[‘encoding’] = “utf8”;

sc_connection_edit(“conn_mysql”, $arr_conn);
sc_change_connection(“system”,“conn_mysql”); ( changing connection to conn_mysql because all apps are using ‘conn_mysql’ in SQL setting

$slogin = sc_sql_injection($login);
$spswd = sc_sql_injection(md5($pswd));

$sql = “SELECT priv_admin,active, name, email, themes_name ,def_lang FROM sec_users WHERE login = $slogin AND pswd = “.$spswd.””;
sc_lookup(rs, $sql, “conn_mysql”);
if(count({rs}) == 0)
{

}

Ok in my generated source I see this:
$sc_sess_db = $sc_session->conect($NM_session_conex, $sc_sess_tab, $NM_session_prod, $NM_session_conf);
This is as far as I know the line to make the connection to the database.
But you would need to switch continuously so I dont think this is so wise. Maybe a well chosen sc_redir might be usefull.
Maybe this article helps you…
http://stackoverflow.com/questions/1565993/oracle-database-link-mysql-equivalent

[QUOTE=rr;39439]Ok in my generated source I see this:
$sc_sess_db = $sc_session->conect($NM_session_conex, $sc_sess_tab, $NM_session_prod, $NM_session_conf);
This is as far as I know the line to make the connection to the database.
But you would need to switch continuously so I dont think this is so wise. Maybe a well chosen sc_redir might be usefull.
Maybe this article helps you…
http://stackoverflow.com/questions/1565993/oracle-database-link-mysql-equivalent[/QUOTE]

Hello rr

thanks for answering, but I don’t need to swith continoulsy. I change my connection on my login app then no need to switch something.

My problem is not there, my problem is that on my login app (control_app) I enter my login and password and I validate, I receive “user doesn’t exist” because select gives nothing then I enter again login and password and after validate everything works.

I suppose that sc_connection_edit() or sc_change_connection() doesn’t change in first step

Thanks

the changed connection is used at the next usage only. I had a hard time with this as well, but worked around by changing the connection then redirecting to an app to make the connection active.

Thanks madikonda,

I will try that

[QUOTE=nacyil;39485]Thanks madikonda,

I will try that[/QUOTE]

Hi madikonda

You’re right, I add a blank app with redir and it’s works.
I suppose it’s a bug in sc_connection command !!

Thanks
Nac