Skip to content
Advertisement

PHP Database Query foreign key data from database

I try to build a simple blog system. database table like below.

Posts

Categories

Post-Categories

I use this code

I know this is not a good way fetching categories.

Even It query same category over and over and over again.

Can anyone give me some guideline/resources/tutorials to learn PHP logics, OOP, Best Practices. How may I handle this with OOP PHP.

And please also provide your ans for fetching categories.

I don’t want to join the post_categories and posts table to fetching data because there are few more columns in there.

Also there may have multiple category in a single post.

Advertisement

Answer

why you don’t want join .. your code is more complex and time expensive that a single joined query

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement