views:

84

answers:

4

Alright, so after years of feeling that I've been doing it the wrong way, what is the best way to interact with a MySQL database, using PHP. Going to start off small-scale, but eventually hoping to grow large scale.

I'd love to be able to use objects, like such

$book = new Book(1342);
echo $book->title;

So, what is the best way to go about using something of a data abstraction layer, or what can I use to accomplish what I am looking towards?

+4  A: 

What you are looking for is an ORM library.

Here is a thread that might help you ~> http://stackoverflow.com/questions/108699/good-php-orm-library

letronje
A: 

You're looking for is called Object Relational Model or ORM. If you're working in PHP check out doctrine: http://www.doctrine-project.org/projects/orm

It also might be worth looking into Ruby on Rails if you're going to be doing a lot of this type of interaction, rails has really nice ORMs.

Ken Struys
A: 

Get a load of Axon ORM

stillstanding
A: 

As a side note:

I would like to point out that most ORM frameworks advise against using object syntax for read-only data.

So while you are actually looking for what is known as an ORM framework (and I do recommend one - such as Doctrine), you will likely be using array syntax in the end for performance reasons.

Craige