PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Sep 20, 2019 2:12 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: the basic of the basics
PostPosted: Fri Jan 03, 2014 6:50 am 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
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:

Syntax: [ Download ] [ Hide ]
$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.


Top
 Profile  
 
PostPosted: Fri Jan 03, 2014 8:02 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Maybe give the a read? PDO isn't a function, it's a class. You instantiate a class using 'new', which calls the __construct method.

_________________


Top
 Profile  
 
PostPosted: Fri Jan 03, 2014 2:37 pm 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
PostPosted: Sat Jan 04, 2014 3:56 pm 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada


Top
 Profile  
 
PostPosted: Fri Jan 24, 2014 12:17 am 
Offline
Forum Newbie

Joined: Fri Jan 24, 2014 12:07 am
Posts: 3
Location: Australia
I think PDO is not a function it is a class.


Last edited by requinix on Fri Jan 24, 2014 1:21 am, edited 1 time in total.
removing advertising


Top
 Profile  
 
PostPosted: Fri Jan 24, 2014 6:52 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat Jan 25, 2014 3:33 am 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
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.


Top
 Profile  
 
PostPosted: Sat Jan 25, 2014 4:30 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat Jan 25, 2014 7:01 pm 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
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.


Top
 Profile  
 
PostPosted: Sat Jan 25, 2014 11:28 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sun Jan 26, 2014 1:46 am 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
thank you Christopher, I will do that. Cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group