Welcome, Guest
Username: Password: Remember me

TOPIC: Table config - data table name

Table config - data table name 21 Aug 2013 19:57 #10872

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi Admin,
After writing up how to split projects www.j-cook.pro/index.php/forum/design-yo...ect-management#10871

I thought of something that will allow connection to alternate data tables

What I propose is to allow users to configure the data source such as #__anytable or #__myproject_sometable (infact #__what_ever_they_like)

In the builder we can specify the table title, item title and associated aliases but what if we could specify the data table?

So how would you implement this you may ask?

if the user has defined an alternate data table
- everywhere that #__myproject_table is called is replaced with #__myalternate_table
- do not generate the create table statement for myalternate_table in the MySQL install file
- do not generate the drop table statement for myalternate_table in the MySQL uninstall file

if the user has not defined an alternate data table
- generate the default Cook Code to call #__myproject_table
- generate the default Cook Create table statement to create #__myproject_table
- generate the default Cook Drop table statement to drop #__myproject_table

So how does this effect the project?
- Effectively my split project routine is a work around to simply change the data source
- The original cook generated table title, item title and associated aliases remain unchanged
- This leaves everything in the downloaded project working exactly as generated
- The only thing that has changed is the data source

What are the benefits?
- Cook Project Downloads effectively are "linked" together without modification
- The downloaded component now connects to any table that is specified in the current database without modification by the user
- Existing Joomla Extensions could be extended by Cook Builders with ease
- access just one field in another component... how many times did you need just one field from another table in another component to further extend its capabilities?

For split projects
- the administrator menu items are no longer Retailer Warehouse, Retailer Head Office they can simply be Warehouse and Head Office
- The component name can now be com_warehouse rather than com_retailer_warehouse
- aliases are shorter

What are the pit falls?
The developer must ensure that all security and states are implemented in each project accessing the table
- published state, checked out, access permissions , core permissions... just to name a few
- some tables have relationships to other core tables, security, functionality that must be understood and probably should not be easily accessible
- lots more pitfalls I am sure

Anyhow just a suggestion
Last Edit: 21 Aug 2013 19:59 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, dyoungers

Table config - data table name 21 Aug 2013 21:06 #10879

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
I like the way you think. Let's see what Jocelyn thinks about it
The administrator has disabled public write access.

Table config - data table name 22 Aug 2013 10:52 #10883

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Thank you for your suggestion.

It is possible now. (or soon)

The only problem remains in sandbox.
Those linked tables could be joomla's natives ones so I cannot let access to any table of the sandboxes. I can imagine the disaster.
Also if those tables are missing, could cause errors.

So in sandbox, cook can create thoses table (remplacement table name)
In your downloaded component, it must check if table effectively exists. Because when you distribute your final product, it must handle properly the missing parts. (Those third tables required)

Finally, in the builder I need also to permit the user to link FK to a table from another project. Making splitting a piece of cake.
It is on the way of reflexion.

Thank you for your suggestions.
Placed as priority.
Coding is now a piece of cake
The administrator has disabled public write access.

Table config - data table name 23 Aug 2013 08:43 #10894

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Finally, in the builder I need also to permit the user to link FK to a table from another project
For Splitting Purposes - May I also suggest also A Primary Key Override As Well

I had a number of projects in Cook 1.5 that extended other non-Cook extensions that required an alternate primary key...
there were a number of areas in the code (and some not so obvious) that had to be changed

I tried to do similar (change primary key from "ID" to "my_id") in a 3.0 project earlier
... got all of what i thought needed changing only to find that it constantly just kept giving me a new record no matter what i did and eventually put that project aside for a rainy day

Just a thought
Last Edit: 23 Aug 2013 08:45 by BTB300.
The administrator has disabled public write access.
Time to create page: 0.062 seconds

Get Started