Implementing a “configurable” joining system, safely

前端 未结 2 1102
予麋鹿
予麋鹿 2021-01-13 07:31

Background

Hello, I\'m developing an experimental/educational tool in PHP and MySQL. I\'m new to SQL, but I want to do things the right way from th

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 07:51

    Assuming that user input is limited to only selecting the tables and fields (i.e. no additional conditions), you should be fine with your approach; sounds interesting :)

    One thing I would like to add is that certain joins are better than others. For example, joining two tables using their primary keys (or other indexes) will perform way better than two unrelated columns for which a full table scan is required.

    This all depends on how big the tables are in the first place; for less than a few thousand records, you should be okay; anything beyond serious contemplation is in place :)

提交回复
热议问题