How to create multiple views of the same table ?

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
azharhussain
Posts: 6
Joined: 2013-01-22 06:40

How to create multiple views of the same table ?

Post by azharhussain » 2013-01-22 06:46

How to create multiple views of the same table ?

Johnk
AppGini Super Hero
AppGini Super Hero
Posts: 68
Joined: 2013-01-09 03:47
Location: Cairns, Australia

Re: How to create multiple views of the same table ?

Post by Johnk » 2013-02-05 12:52

You can copy a table and give it another name: Current Suppliers (Filtered) and all suppliers. As far as I'm aware, each table can access the same database and modify the same records depending on the filter of course. If you want both tables to appear on the same page, this tutorial should help:

http://bigprof.com/appgini/tips-and-tut ... -same-page

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: How to create multiple views of the same table ?

Post by toconnell » 2013-11-18 13:39

The question really was not answered.. you said it CAN Be done and supplied information on how you can put two tables on one page, but not how to change a view. I have this same question. I have to "dummy proof" my database and want to limit the fields a user can access and enter by role. So I would like to take my bus_status table and create a different view that only contains 4 of the 16 fields for entry.. just these 4 required fields for the record. Then another view for another user that will complete the other 12. Having the one user see the other 12 is a problem as they fill out the 4 fields on a phone. So space is at a premium. It would be very helpful to find out if I can do this. Is it possible? If so, HOW is is done? Just save with a new name and edit? Where will it appear? Will it be in the drop down and the home page menu?

I really apprecieate your help John or Amad, or anyone who knows.


Thanks, Tina
Tina O'Connell
Web Dev & Appgini FAN

artemisia
Veteran Member
Posts: 59
Joined: 2013-10-01 15:50

Re: How to create multiple views of the same table ?

Post by artemisia » 2013-11-18 21:26

A user posted this possible solution in the Tips & Tricks section:
"Use AG membership table for users in app"
http://forums.appgini.com/phpbb/viewtop ... 1863#p1863

It used a view of a table, and restricted user rights to another table. I haven't tried this yet but will sometime next month.

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: How to create multiple views of the same table ?

Post by toconnell » 2013-11-20 20:53

Actually this is not at all what I mean Artemisia. I could just create the new table inside appgini and then copy the fields and properties in appgini from the other table. Do the build and wala.. done. But no.

I am talking about the finished application when it is all built and working. For example your employees table. maybe you have social security number as part of the table but some users should not see that field for security reasons. I want to create another view online of the employees table like employees2 that will allow those users to only see the fields and only edit the fields I choose.
That is what I mean. This program is an interface to mysql database. I would NOT be adding another MYSQL table. The new "view" would simply only enter some of the information in the employees table that already exists. 1 would have all the fields in the table and the other limited to only the fields I need that user to see.

In my case the real table name is bus_status. It has details like bus number, location parked, in service or out of service status, dates in our out of service, work done, make, model, year, and serial number information, notes and such. It also has a way to MOVE a bus using the table fields moved from location, moved to location, reason for move and date of move and who authorized. The folks here that enter that are usually using their phones and really need to only access those 5 fields of the 23 fields in the table. So I want a view for them they can use on their phones to only show those 5 fields from the table of 23 fields.

Thanks, Tina
Tina O'Connell
Web Dev & Appgini FAN

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: How to create multiple views of the same table ?

Post by toconnell » 2013-11-27 14:56

Well it was tricky but I got it to work..
Created my role based limited view of a table with all the permissions and structure intact. It worked and was tested in sandbox mode on a dummy copy of the database and no data loss.

Here is how to do it.

Go into Appgini. Make a copy of your apx file with a new name. in that file delete all tables you do not want to appear for this user role and leave only the tables you want to use. Then inside those tables delete all fields that you do not want this user to see. HOWEVER DO NOT DELETE ANY REQUIRED FIELDS OR ANY PRIMARY KEY FIELDS or it will not work. Leave those in.

Save the file then output to a newly named folder. Delete the contents of that folder and change something simple on a table like a description of the table then re-output. If you do not you will have alter and delete and drop commands delete those tables and fields from your full database which you want to leave alone. By deleting the output file and rebuilding after a minor change you eliminate those drop table and alter table and delete fields commands form the php output. This final file you post to your server connecting to your original database and wala you will have a view that is dummy proof that only has the fields you need that user/role to modify without them seeing or accessing all the other fields you don't want them too. In my case this was for users on the road to move buses and they only neeeded 4 of 23 fields to do this. This interface addition made it so they could do it in 5 seconds not 10 minutes. Big difference in operational management but little work for me. I tested the output file first on a mysql copy of the database I used as a sandbox. You can make a test copy of your database using PHPMYADMIN and going to the synchronize tab and copy y our database to a new name. Test it play with it and make sure there is no data, field or table loss before you update the file to your working copy of the database. Otherwise.. great way to build alternate databases.
Tina O'Connell
Web Dev & Appgini FAN

Post Reply