Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:03:28+00:00 2026-05-25T02:03:28+00:00

So what I currently have is my tables in SQL, with table connecting different

  • 0

So what I currently have is my tables in SQL, with table connecting different table, e.g.

Table1: id, identifier, other_attributes
Table2: id, identifier, other_attributes
Table3: id, table1_id, table2_id // this connects table 1 and 2.

So I have made an object for table1 and table2, allowing things like $table = new table1($id); and $table->getName(); or $table->setName();

However, I’m not quite sure if this is the best way? And if it is, would it be best to create another object for table3? or is there better way to do this?

Finally, what I’ve done is combine getters and setters, meaning $table->name('somename'); will set the name, and $table->name(); will get it. Is it wise to combine them? or better to separate them?

Hosh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:03:29+00:00Added an answer on May 25, 2026 at 2:03 am

    I would use objects for each really used object (as the name states somehow…).

    For example I have a single user-class, which uses data from three different DB-tables. The n:m relation-tables should be implemented as their names indicate. Having a table ‘user_has_address’, I would implement the SQL-queries on the user-class too (which the uses an Address-class). But data from a table like ‘company_has_employees’ would reside in a company-class.

    And how to name your getters and setters in PHP is a matter of coding-convention (e.g. in your company or just your own). You don’t need them at all in PHP when using magic-methods (like __call()), but as noted by @JJ, it would make testing easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a table structure that looks something like this(some details omitted): ColumnName
SQL 2005, 600,000,000 rows. I have a table called Location currently using the data
Greetings, I have some mysql tables that are currently using an md5 hash as
I have a question about tables in MySQL. I'm currently making a website where
I currently have a Table [org.eclipse.swt.widgets.Table] with several TableColumns; however, due to UI space
I currently have a table with a nested table in it: <table class=datagrid id=report>
I currently have a table which only has a single editable column. I have
Say I have a table with a unique positive integer field. I currently have
I'm trying to normalize a mysql database.... I currently have a table that contains
Currently we have a table that we use to track inivitations. We have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.