Jump to content

[SOLVED] using an alias to a database name in a query


_giles_

Recommended Posts

Hi all,

 

Is there any way that I can use something like define() to create an alias to a database name in a MySQL query? e.g. I currently have something like

 

$result = mysql_query

(

"UPDATE DestDb

SET

answer = '$answer'

WHERE session_id = '$session_id'

AND count = '$count_history' "

);

 

 

and it wold be great if I could do

 

define("L_DestDb", "DestDb");

 

and subsequently use

 

$result = mysql_query

(

"UPDATE L_DestDb

SET

answer = '$answer'

WHERE session_id = '$session_id'

AND count = '$count_history' "

);

 

that way I can alter “DestDb” without having to trawl through my increasingly large project hunting out database instances!

that would work if you escaped the query string like "SELECT * from ".L_EstDb." WHERE...." otherwise, you can't parse a constant within a string, no matter what you'll probably end up hunting down all the sql calls. easiest to use a code editor and use replace function

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.