Forums

Variable in Table name

Eemuli 19 Mar, 2010
Hi !

I have a situation where different users have their own database tables. Tables are named like this:

data_user1
data_user2
data_user3
...and so on.

The structure in every table is the same.

I want to show information to logged in users from their table, but I found this pretty difficult. If I want to show the data, I'll have to configure a different ChronoConnection form to every user individually.

To avoid the huge amount of work, I could introduce a variable to "TableName".


Example:

Instead of selecting the table from drop down menu, I would write some php code to echo the name of wanted table. Code could be something like this:

<?php 
$user = JFactory::getUser();
echo 'data_' . $user;
?>


Then every time the form uploads it checks the username and selects the right table to fetch the data.

And the user interface could look like this:


[attachment=0]variable.jpg[/attachment]


Is this improvement possible to do? Or can I already fetch data like this?


Eemeli
GreyHead 19 Mar, 2010
Hi Eemuli,

Sorry, the only way you could do that at present is by hacking the ChronoConnectivity code - it's probably possible but I wouldn't guarantee it.

The other approach would be to use MySQL to create a single temporary table with all your users data in it and run ChronoConnectivity against that.

Bob
Eemuli 19 Mar, 2010
I'll probably add a temporary table for now.

Can I somehow help you in adding the variable feature to ChronoConnectivity?


Eemeli
GreyHead 20 Mar, 2010
Hi Eemuli,

Thanks for the offer I do have a heavily hacked version of ChronoConnectivity that can accept complex SQL queries, I hope to find the time soon to get it into a publishable state.

Bob
Eemuli 21 Mar, 2010
Sounds good! I look forward to it.


Eemeli
mbwallace4 19 Nov, 2010
I would like to see that, too. And I'm hoping it would have somewhat a phpmyadmin feel to it -- less learning curve.🙂
This topic is locked and no more replies can be posted.