1

Are there any great, lightweight MySQL connection classes out there for PHP that anyone recommends?

I have written my own, and I do think it is pretty good but this seems like the sort of thing that many programmers better than me must have perfected long ago.

I'm interested in finding something that I can slot in generically and use as I need it with as little hassle as possible.

Some generic functions to support querying, connecting to multiple MySQL databases within the one application would also be a plus.

2
  • 1
    I am happy with just one function and no classes nor multiple connect support. It's all seems overkill to me Commented Aug 25, 2010 at 10:04
  • 1
    What's wrong with ext/mysqli (apart from messy prepared statements API)? Commented Aug 25, 2010 at 10:05

6 Answers 6

4

Have you had a look at PDO? http://php.net/manual/en/book.pdo.php

Sign up to request clarification or add additional context in comments.

Comments

2

PHP's PDO (PHP Data Objects) extension is my recommendation. I use it alongside a light-weight database class that extends PDO. You can find this open-source project on Google's Project Hosting at http://code.google.com/p/php-pdo-wrapper-class.

Comments

1

A class of my own invention: DB

It may be called very lightweight (less than 100 lines of code). It is a wrapper around PDO and it actually only adds a very handy way of escaping variables and a short syntax (DB::query() instead of DB::instance()->query().)

But this short syntax results in it being limited to once connection.

Comments

1

The simplest and lightweight db class is

http://code.google.com/p/edb-php-class/

<?php
$result = $db->q("select * from `users`limit 3");

foreach($result as $a){
        $a = (object) $a;
        echo $a->id.' '.$a->name.' '.$a->url.' '.$a->img.'</br>';
}


$result = $db->line("select * from `users` where id = '300' limit 1");
echo $result['name']; 
echo $result['surname']; 



$name = $db->one("select name from `ilike_pics` where id = '300' limit 1");
echo $name;
?>

Comments

1

this is a very neat and easy to use class: http://justinvincent.com/ezsql

wordpress database class is also derived from the above class

2 Comments

links to site about blenders. spam?
@juggleware LOL looks like Justin Vincent doesnt own that domain now, so I have updated the link. You should probably have checked my profile and the cached version of the page, before marking it as spam. I am not supposed to update links if the author chooses to disown a domain :)
0

May try ADOdb and ADOdb Lite

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.