+ Reply to Thread
Results 1 to 2 of 2

Thread: php connecting to db

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    php connecting to db

    I have never worked with PHP classes or PDO before. But I think it is time that I start to learn before things get really outdated.

    so as I was googling my way trying to find examples/tutorials. two things stood out to me.
    1) PDO
    2) custom DB classes

    I was wondering which one is better to use, providing more security, ease to read/understand, etc.
    also, if custom DB classes are better, can someone provide me with a link or attach it to the post?

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: php connecting to db

    It's not necessarily an either/or situation. Use PDO, because it offers custom queries, integrates with SPL (the PDO drivers use exceptions and PDOStatement implements Traversable, so you can use it in foreach loops). Also, Don't Repeat Yourself (or others). If there's a particular feature you need, use inheritance or class composition to extend PDO. The DB access code should be hidden behind the public interface between the data access layer and the rest of your app; make sure the features you introduce to the db access classes don't belong somewhere else in the data access layer (hint: if the features are to be visible beyond the DAL interface, they don't belong in the DB access code).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers