Page 1 of 1

the basic of the basics

Posted: Fri Jan 03, 2014 5:50 am
by jaad
Hello all.

I always find it hard to find the most basic information about the most basic concept in php. I literally waste 2 hours a day browsing through books or forum to get the simplest question answered.

Let me give you an example of what I was asking myself a few minutes ago:

Code: Select all

$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'], $config['username'], $config['password']);
You all recognize a new instance of connecting to a database. I understand the concept really well and can do it my eyes closed. What I never been able to understand is the syntax. can anyone help me with that?

When I look at the php manual this is what I see:

my number one question: Let's say I wanted to learn what the new PDO function does and how to properly format it I would first go the http://ca1.php.net/manual/en/class.pdo.php to read about it. Unfortunately there is no mention anywhere to a function called PDO() the closest thing I can find is PDO::__construct() ( string $dsn [, string $username [, string $password [, array $driver_options ]]] ).

what am I missing here? How can I learn a function when I can't find it in the manual? How would I be able to make an association from PDO() and PDO::__construct() or am I not understand how the information that is provided to me in the book? I have tried to look for how the book is organized section and but can't find that either.

Re: the basic of the basics

Posted: Fri Jan 03, 2014 7:02 am
by Celauran
Maybe give the OOP basics a read? PDO isn't a function, it's a class. You instantiate a class using 'new', which calls the __construct method.

Re: the basic of the basics

Posted: Fri Jan 03, 2014 1:37 pm
by social_experiment
jaad wrote:I literally waste 2 hours a day browsing through books or forum to get the simplest question answered.
Perhaps you should also look at better resources or ask different questions on forums like devnetwork :)

Re: the basic of the basics

Posted: Sat Jan 04, 2014 2:56 pm
by jaad
Celauran wrote:Maybe give the OOP basics a read? PDO isn't a function, it's a class. You instantiate a class using 'new', which calls the __construct method.
I really feel like I learned something today, thank you. How silly of me. (after I was able to read and understand what a class is) I managed to find an incredible tutorial that explains what classes are in really plain English at http://devzone.zend.com/6/php-101--php- ... -beginner/

If you are like me and struggle with making sense of the lingo and syntax - this little tutorial will totally change everything for you.

Re: the basic of the basics

Posted: Thu Jan 23, 2014 11:17 pm
by Adnig
I think PDO is not a function it is a class.

Re: the basic of the basics

Posted: Fri Jan 24, 2014 5:52 pm
by Christopher
jaad wrote:If you are like me and struggle with making sense of the lingo and syntax - this little tutorial will totally change everything for you.
It is a struggle to understand the jargon of OOP. But once you get it, it will open up a new set of ways to solve problems. Now that you have a basic understanding, please feel free to ask specifics on OOP implementation and theory.

Re: the basic of the basics

Posted: Sat Jan 25, 2014 2:33 am
by jaad
Well thank you very much for the encouragements and your gracious offer to let me continue to post on the site with my questions. I took a week off to really sink my teeth into the application that I am trying to build and after a week, I realize that I am in it way over my head. There is no way I will ever be able to reproduce the application that I created in MS access in a web application. The sheer size and complexity of the application makes me think that I will require a minimum of 5 years simply to learn the basics of PDO. I just don't have the time to wait that long. There is simply not enough good literature on PDO that I can understand. I decided I am better off dropping PDO and learn how to build my application through procedures instead. At least there is plenty of literature on the topic and I will be able to move forward with my project at least. I'll come back for sure to ask questions lol, no doubt about that! but it will be more likely be about mysqli and weird table join questions lol. cheers.

Re: the basic of the basics

Posted: Sat Jan 25, 2014 3:30 pm
by Christopher
jaad wrote:Well thank you very much for the encouragements and your gracious offer to let me continue to post on the site with my questions. I took a week off to really sink my teeth into the application that I am trying to build and after a week, I realize that I am in it way over my head.
It may seem that way.
jaad wrote:There is no way I will ever be able to reproduce the application that I created in MS access in a web application. The sheer size and complexity of the application makes me think that I will require a minimum of 5 years simply to learn the basics of PDO. I just don't have the time to wait that long. There is simply not enough good literature on PDO that I can understand. I decided I am better off dropping PDO and learn how to build my application through procedures instead. At least there is plenty of literature on the topic and I will be able to move forward with my project at least. I'll come back for sure to ask questions lol, no doubt about that! but it will be more likely be about mysqli and weird table join questions lol. cheers.
Is it really just PDO that you are having a problem with, because it is OO? It really won't take you 5 years to learn the basics of PDO. You have only showed one line code so far. Can you post the PDO code you tried. I really should not be too hard to get it working.

Re: the basic of the basics

Posted: Sat Jan 25, 2014 6:01 pm
by jaad
well it's not really the codes that I am having difficulties with, it is more about understanding what is going on in my pages. I purchased a couple of great video tutorials and I understand a lot of the logic with classes, methods and all that. I read a lot of books too. I also get responses from forums too sometime... The problem with this whole thing is nobody use the same style when it comes to writing codes. Whether procedural or PDO everyone have a different way of looking at something and then use different tools(functions) to build it. Take a little bit of this here and a little bit of that there mean I have to constantly modify my codes in order to make things work in harmony. The only way I can see myself progressing with this is if I would find ONE author who talks about everything and how it all works together while always being consistent with his/her codes. I haven't' found such an author yet and when I do, this is when I will first start to learn something I think. I did however found an easy to read and follow series of books by O'Reilly called Head First! I have been working on Php mysqli book since last week and I have learned a few things, which is great! Unfortunately the series of book doesn't' include anything about PDO only procedural which is too bad because I have a really good start on my application in pdo but now working on engineering back into mysqli since I can at least understand what is going on in my pages.

Re: the basic of the basics

Posted: Sat Jan 25, 2014 10:28 pm
by Christopher
No author or book will address everything you need and how it works together. Fortunately or unfortunately, you need to struggle through comprehending the concepts. If you post actual chunks code, rather than staying theoretical, we can provide a lot of help.

Re: the basic of the basics

Posted: Sun Jan 26, 2014 12:46 am
by jaad
thank you Christopher, I will do that. Cheers