0
I am new to PHP and Zend Framework 2, I am passing on a project written in C# ASP.NET to PHP using Zend and I came across the following problem.
I have 2 tables: user and street.
In the user table I have: id, name, email, password.
In the street table I have: id, id_usuario, address, number.
How do I insert/update both tables correctly?
How should the User and Street model be created? Together, separate? The mapping of the table (Usuariotable, Logradourotable) together, separate?
What would the Forms issue look like? Folder organization?
Whether two entities will be used or only one depends on the business rule of your Felipe application. Are two tables really necessary? Can a user have more than one address? If yes you need two models, otherwise you do not need to normalize and the user can contain all attributes (address and number)
– gmsantos
@gmsantos, it would be more for organizing the tables, and I will also use a third table to search data on the street of several users, so I think it would be easier to pull this way the select. Because in fact, the scenario is that I have a table of cities, states, street and the user himself. The table of cities has the code of the state, the street has the code of the city and the user has the code of the street. I just wanted to understand how this matter of inserting into multiple tables would work... Can you help me?
– Felipe A.
Felipe, your doubt is quite specific the way it is. If the doubt is to insert in more than one table just create two Inserts. Now helping you with the full implementation goes beyond the scope of the stack overflow. I recommend that you read the [tour] and also [Ask].
– gmsantos
All right, thank you very much... but could you give me an example of how I would do that? If I need to, I can put the structure of my project, which is in each file...
– Felipe A.