tags:

views:

187

answers:

5

Hi ,

If I made my PHP code which would connect me to my MySQL database in a separate PHP file and made a require on the necessary pages of my website would the DB Connent PHP file be an Object Orentated item ?

+3  A: 

OOP is a concept. So if you include a file via the require command and this included file utilizes OOP then your script uses the concept of OOP. If not then your mainscript doesn't include it, too.

Henrik P. Hessel
That depends on the code!!!!
Mez
A: 

That depends on the code in the seperate file. If it's within a class that you call, rather than just a set of functions, then yes. If not, no.

Mez
Could you explain more what you mean :) Thanks
Oliver Bayes-Shelton
http://uk.php.net/manual/en/language.types.object.php
Mez
A: 

Of course. You could also use MySQLi, which is object oriented as well.

Rusky
+3  A: 

Oliver, Check out this link about object oriented PHP. It will give you a basic intro and then you can determine if indeed your code is object oriented.

AieshaDot
which link? I don't see one :)
Henrik P. Hessel
Just corrected it. Check it out now. Sorry first SO answer. :-)
AieshaDot
+1  A: 

You need to know that basically require only puts the text from the required file into the executing .php file.

So it doesn't make your code any more OOP by requiring another file, it just makes it more structured and maybe more maintainable in the future, but not OOP.

OOP would mean that you have created some sort of object that you call from now on to execute commands against. You can read more on OOP in Wikipedia

I strongly suggest you read the book "Code Complete" if you are just beginning with programming and just keep on experimenting. The road to OOP programming usually leads through lots of bad procedural programming (that's what you are most likely doing right now).

Tigraine