Database Class

Hi,

I’m building an extremely basic Guestbook app, for kicks, and wondered if someone would be kind enough to post or link me to a solid Database PHP Class.

I’m hoping it would allow for the usual CRUD operations, so ultimately in a script I could run something like:

$this->mysql_insert('news',$data);

And this would insert my data into the table.

Or perhaps

$this->mysql_select('news');

would retrieve records.

Any escaping functions in the class would be a bonus :slight_smile:

Just something basic to get me started.

Many thanks for any help.

Learn/use Codeigniter php framework

Good call.
I do use it, but just wonder if there’s any pre-existing classes too.

PHPClasses.org seems like a good resource actually.

Not really what you’re asking for, or even what you’re after but you may find Doctrine interesting.

It allows for some rather sexy code.

IMO. :smiley:

Site - [URL=“http://www.doctrine-project.org/documentation/manual/1_2/en”]Documentation - [URL=“http://www.doctrine-project.org/documentation/cookbook/1_0/en/my-first-project”]Tutorial

Just throwing that out there.

To answer your question though, you should be looking at PDO. If not, why not?

Maybe try this one: http://phpclasses.realsauce.com.au/package/3270-PHP-MySQL-database-SQL-queries-wrapper.html

Alternatively, look for the PDO abstraction class on the phpclasses site, they have a neat class on there. I cant login at the moment (away from home and cant remember my goddam password). But search for that, its the one I use alot, veruy flexible and handy.

I have heard good things about doctrine.

You could also use some Zend classes. They can pretty much be used in isolation although they might be a bit overkill.

Having used CI and looking at your request it seems their version of ActiveRecord is what you want, else for simple single table CRUD support look up that ActiveRecord pattern.

I think I remember seeing someone posting something like that which was PDO-based, but am unable to find it.

If you’re really looking for something simple, then I highly recommend:
http://www.ricocheting.com/code/php/mysql-database-class-wrapper

Yep, I’m definitely going to stick with CI for now. No point reinventing the wheel.

When I get a chance, I may look over Zend too.

Thanks again for the help and links, will look into them soon.

You might also want to look into Yii.

http://www.phpclasses.org/browse/file/21512.html

http://davidwalsh.name/php-generic-objects-organize-code-class