⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Edit other table fields(merge 2 table fields)



lucaweb85
  • profile picture
  • Member

Posted 21 February 2013 - 11:02 AM

Hi guis, I have 2 tables

 

users  and  company, company is an estention of users at this time.

 

I only want to merge users fields and Company fields in One Edit/Insert form whiout change the database structure.

 

example

 

Users

- idu

- email

- password

 

Company

-idc

-name

-about_us

-site

......

-idu( foreign key for users table)

 

 

My Form fields for Company

 

Name, email(from users),password(from users), about_us,site...

 


davidoster
  • profile picture
  • Member

Posted 21 February 2013 - 14:20 PM

You need to make a third table in order to make this.

Think about it...

You have one table called company, so you could have many companies as individual records and then you have the users table that can also be many and even exist into different companies.

The only way to relate companies to users (or vice versa it doesn't matter) is by having a middle table called company_users which in essence needs only 3 fields,

id, idc,idu

 

I suggest you read about relational databases on the internet before trying to make a system. Strong theoretical background is needed before building a system.

Also I must say that this is not a GroceryCRUD related question and it shouldn't be here.


victor
  • profile picture
  • Member

Posted 21 February 2013 - 17:17 PM

I think him case is one user only has one company. I make the same project. You can make a custom model.
By the way I don't use the GC in difficult cases.

davidoster
  • profile picture
  • Member

Posted 21 February 2013 - 19:12 PM

I think him case is one user only has one company. I make the same project. You can make a custom model.
By the way I don't use the GC in difficult cases.

 

Is this really a difficult case?


victor
  • profile picture
  • Member

Posted 21 February 2013 - 19:21 PM

No, it's reality simple case. But I make it without GC about 15 minutes. I use GC there where it's convenient.

victor
  • profile picture
  • Member

Posted 21 February 2013 - 19:28 PM

Maybe I don't understand the question. My English is bad.

victor
  • profile picture
  • Member

Posted 21 February 2013 - 19:38 PM

I use the add_action and make customs functions for the add and edit actions.

davidoster
  • profile picture
  • Member

Posted 21 February 2013 - 22:12 PM

Well, [member=Victor] the way he made the question shows an inexperienced person in relational databases.

I mean no disrespect but this is the truth.

Look:

A. he wants to somehow merge information from 2 different tables

B. he doesn't want to change the current structure of the tables

C. the two tables don't have any foreign keys in order to identify foreign records

 

There are only two options in order to "merge" information from different tables:

1. foreign keys to one of the tables

2. a new table having as foreign keys fields from these tables

 

And since B exists you can't do it without making a new (third) table.

All this goes back to know how to use a relational database.

If he makes the third table then we can help me how to implement it in GC!


lucaweb85
  • profile picture
  • Member

Posted 22 February 2013 - 08:59 AM

No, it's reality simple case. But I make it without GC about 15 minutes. I use GC there where it's convenient.

 

 

You understand my problem, at the beginning i think about a 1_n relation (1 user many company) but then i realized that I did not need this.

Whitout framewroks i do this whit a simple inner join query and write my custom html input form. But i want to keep the power of GC.