This topic is locked

change table on runtime

3/18/2024 6:26:14 AM
PHPRunner General questions
H
h.hermsen@venlo.nl author

i want to use a specific table for every user

can i make a

query like

SELECT
dbo.Application_select.Id,
dbo.Application_select.Name,
dbo.usertable+ ':session.UserID'.dataset,
FROM dbo.Application_select
LEFT OUTER JOIN dbo.usertable+ ':session.UserID' ON dbo.Application_select.Id = dbo.usertable+ ':session.UserID'.dataset.record_id

C
cristi 3/18/2024

Depends on what you want to achive...

You can capture the table name from the link:

$URIParts = explode('?',$_SERVER['REQUEST_URI']);
$URI = explode('/',$URIParts[0]);
@array_shift($URI);

while ( @count($URI) > 0 && !end($URI) ) {
@array_pop($URI);
}
$_SESSION["table"]=strtok($URI[1],'_');

Then you can use the session in a php/mysql query - not directly in a SQL query!

admin 3/19/2024

Creating a SQL View should be a way to go. Create a SQL View first, switch to PHP code mode. Then in PHP code mode you can change the table where data is selected from.