php-general Digest 15 Dec 2010 14:12:22 -0000 Issue 7088

Topics (messages 310039 through 310041):

Re: good, popular?
        310039 by: Paul M Foster
        310040 by: Larry Garfield
        310041 by: Nicholas Kell

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Tue, Dec 14, 2010 at 03:10:56AM -0800, Sam Smith wrote:

> Searching for "PHP CRUD" in hopes of learning the best way to access
> databases and to use PEAR or what I came across PDO.
> 
> I want to know the communities opinion of PDO: everyone uses it or no one
> uses it or it's great or what?

I use PDO within a class which handles various housekeeping (error
handling etc.) for everything. PDO handles all the popular RDBMSes (as
far as I know). It can also "sanitize" queries to avoid SQL injection.
Simple interface. It's also part of PHP, meaning it's well tested and
solid.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Tuesday, December 14, 2010 1:02:33 pm Lester Caine wrote:
> [email protected] wrote:
> > I'm the DB maintainer for Drupal 7, and we rebuilt our entire DB layer
> > on top of PDO.  It's a rather nice API, although as others have noted it
> > does not abstract away SQL entirely; it abstracts the API calls you need
> > to use to get to SQL.
> > 
> > We then built a layer on top of that which does abstract away most
> > database weirdness using fluent query builders.  It's much
> > lighter-weight than an ORM.  I'm in the process of spinning it off as a
> > stand-alone library because we think it's that cool, but it's not
> > completely divorced from Drupal yet.  Stay tuned. :-)
> 
> Larry - how many databases does it actually work with? Having rebuilt the
> DB layer using PDO did you actually gain anything?

Drupal 6 and earlier supported MySQL and, kinda sorta, Postgres, maybe.

Drupal 7 ships with support for MySQL, Postgres, and SQLite out of the box and 
add-on modules provide support for Oracle and MS SQL, within reason.  So we 
increased our DB support from 1.5 to 5, essentially.

We also gained, as part of the rewrite, untyped prepared statements, 
transactions, and master/slave support (although that's nothing to do with PDO 
per se, just our layer on top of it).  And that allowed us, in turn, to build 
type-safe query builders, support for MERGE queries, and all kinds of other 
fun stuff on top of that.

> PDO still needs a number of areas finishing before it can become a total
> replacement for the legacy stuff that is available such as the PEAR
> libraries and the likes of Drupal writing their own abstraction layer on
> top of it ... along with a number of other projects who are now doing the
> same thing ... shows that PDO is not creating the common platform it was
> supposed to :(

That is, sadly, true.  PDO is not a complete and perfect DB library, in part 
because there are few people who work on it, and fewer still who understand 
all of the vendor-specific issues at hand and the vendors have been very slow 
to lend a hand, preferring to work on proprietary APIs.  It's quite 
unfortunate, but I still consider PDO an overall win.

If anyone knows C and wants to make a name for themselves in the PHP world, 
PDO is looking for some heroes. :-)

--Larry Garfield

--- End Message ---
--- Begin Message ---
On Dec 14, 2010, at 5:45 PM, Govinda wrote:

>> In previous experience with questions such as these, you will get
>> several types of individual responses to usages of the software. Some
>> good, some bad, depending on the experience level of the commenter
>> with both the language and the code in question.
>> 
>> It's a combination of your current understanding of php and the
>> associated usages of other languages, and what you want to know.
>> 
>> Don't trust what people say, trust what feels right at the current
>> time of your usage of the php library available/your experience level,
>> and what you currently know how to use.
>> 
>> From my experience with several languages, once you know the basics,
>> even if you do re-invent the 'wheel', so did firestone,michelin, and
>> goodyear, and they're not complaining. And you'll feel better for
>> reinventing, than using someone elses.
> 
> 
> I think this ^^^ advice is brilliant, understated; nothing replaces 
> integration of one's own thorough understanding.
> 
> ------------
> Govinda
> govinda(DOT)webdnatalk(AT)gmail(DOT)com

@the OP

I absolutely agree.

One-thousand people will miraculously come up with two-thousand opinions on PDO 
and similar tools. PDO is only one of many, many tools in your toolbox.

At the end of the day - get ahold of PDO, mess around with it a bit, read some 
docs, etc.. See what you can do with it, then see if it was worth the learning 
curve and how you can leverage your newly found knowledge on your next project. 
Then, drop it like it's hot when you don't need it. No need to jam a square peg 
in a round hole. Whip out your pocket knife and make a round peg for a nice 
snug fit. After all, that's why you carry a pocket knife - right?


If it feels good - do it.

--- End Message ---

Reply via email to