I have 2 mssql database with the same table structure
currentdatabase.table1
a) date
b) particular
c) amount
** Here I store all the transaction for 30 days
backupdatabase.table1
a) date
b) particular
c) amount
** Here I store all the transaction for 1 years (but not the data in the currentdatabase)
I have created the project using the currentdatabase
On the List page of table1 I have made the External search on date
Now I would like to change the database according to the date put on the external search
eg.
If I search the the date 25/05/2020 then the database should be currentdatabase
and if I search the date 01/01/2020 the the database should be backupdatabase
A simple solution will be to set up the two databases as two link databases (say, linkdb1 and linkdb2). You can then switch the default database between the two link databases in server event:
if (…)
$GLOBALS[“Conn”] = Conn(“linkdb1”);
else
$GLOBALS[“Conn”] = Conn(“linkdb2”);
In the ewcfg.php under the CONNECTION_INFO array I have enter the line as
“DBBACKUP” => [“id” => “DBBACKUP”, “type” => “MSSQL”, “qs” => “[”, “qe” => “]”, “host” => “localhost”, “port” => NULL, “user” => “”, “pass” => “”, “db” => “backupdatabase”],
And I try to change the database from the CustomViews—TableSpecific—Listpage—Page_DataRendering server Event as
$GLOBALS[“Conn”] = Conn(“DBBACKUP”);
here the database does not change And my list page still showing data from the “DB”
You should not use the main global database connection variable to change to another database. You should create another global variable for your other database connection.
I have created two linktable
first linktable is currentdatabase1
second linktalbe is backupdatabase
Now I have created a list page from the first linktable
I try to change the Conn using the Server Event at Page_DataRendering as
var_dump($GLOBALS[“Conn”]);
$GLOBALS[“Conn”] = Conn(“backupdatabase”);
var_dump($GLOBALS[“Conn”]);
The first var_dump show the currentdatabase1
and the second var_dump show the backupdatabase
But in the list page it only show the record for currentdatabase1
I want to change the database according to the Search date enter in the External search.