Thanks a lot for your replys. To give you an idea about my "newbidity" here is what I don't understand:
What is a factory and what does it do?
Why using a try catch inside the constructor will help me?
(assuming that "around a call to the parent constructor" is the same as: "inside the constructor").
I see a lot of getters and setters on examples around the web, and books, but no one seems to care about the explanations of this methods. I mean, I know, because I've read, that we cannot access the properties directly, but I don't know why, and why we need get and set methods. (that now i've learn we call them mutators)
What are class extensions?
So... according to all this, I must execuse myself. This is my first class, (and what a class I may say). But I've learn a lot already (automotivating moto).
So I propose we stick with one answer and we digg in, till I'm able to understand the answer you have give to me.
So, my question is now: will you be able to help me understand the answers provided ? It will take a lot of Q/A I believe...
1) I have been told that we should use a class, among other advantages, to better organize our code, and that the future of PHP is OO.
According to this, I'm learning PHP directly the OO way.
2) I have been told that PDO is the way to go, and we should more or less forget the mysql and mysqli methods. So, that's why I'm learning PDO.
3) I wish to use a prepare/execute PDO method because I've read that it's more efficient if you want, for example, prepare a query, and then execute it several times, like on a "multiple insert record" scenario.
If this is correct, then I should proceed with this.
What I'm trying to accomplish:
Understand a class that uses:
Not mysql or msqli functions but PDO -> to connect to the database. -> DONE. (it works and I understand)
Not use the (query / exec) but PDO Prepare/Execute; -> To access database data.
Not use fetch_assoc but, Fetch_obj; -> To fetch the data from the database as objects..
Assuming that, those are the best tools we have to properly develop OO PHP.
The gap here is that, I have read about all this separatly, but never all toghether, and never all on a class.
More then code, I believe I need to understand the big picture of this all, and for that I will need your help.
Thanks a lot,