tags:

views:

71

answers:

2

Hi, I'm looking for a many-in-one PHP MySQL 1 class/file with the features:

  1. Connect to DB server
  2. Select database
  3. CRUD
  4. Prepare & binding

Thank you in advance!

A: 

After a quick search I found this.

You could modify / extend it to suit your needs.

Christian
Thank you Christian! This class is simple enough.
Viet
+1  A: 

Here is a little something I wrote a while back:

MySQL Class

Then you can just query as such:

$mysql = new MySQL('localhost', 'user', 'password', 'somedb');
$mysql->open();
$result = $mysql->query("SELECT field FROM table WHERE field = '%s';", 'Some Value');

while($row = $mysql->fetch($result)) { echo $row['field']; }

It will automatically escape your values, provided you use sprintf() type syntax. Not exactly what you asked but close.

For a more complete package, you might want to look at PEAR::MDB2.

Andrew Moore
Thanks Andrew! Good job on that! I just need a simple one and your is quite complete for my needs!
Viet