开发者

Is writing a PHP page for each query a good programming skill?

开发者 https://www.devze.com 2023-01-14 21:43 出处:网络
Actua开发者_开发问答lly I got selected in one of the company. They were working in PHP from quite a long time.

Actua开发者_开发问答lly I got selected in one of the company. They were working in PHP from quite a long time.

I worked for just 1 week over there, but the thing which I saw over there is that they used to write one PHP page for each table and they used to include those file and pass some variables to it and getting the array of variables in return from those classes.

It did not put me off at that time, but I tried to use it now. What I am not getting: is it a good practice to write a class for each table in your database and letting all the SQL part in that query?

How would a script for at least one table look like?


This is quite a good idea if I have understood your question right. See the model view controller paradigm for more information: Model–View–Controller (Wikipedia article).

It's a kind of encapsulation.


Your post seems a bit confused.

One php page per query doesn't make any sense at all.

One php file per query - that's a different story - and a good idea. It abstracts the 'Business logic' implemented within PHP from the data model. And isolates the PHP code from changes in the underlying database schema - and vice versa.

include those file and pass some variables to it

You should never invoke functionality using include/require - it should always be called explicitly. Or is that what you meant to say?

one php page for each table

For each table or each query? The former is very stupid - if you need to query multiple tables to get a result set then this should always be done in a single query so the DBMS can optimize it.

0

精彩评论

暂无评论...
验证码 换一张
取 消