views:

90

answers:

2

Several months ago my work deployed an in-house function that wraps the standard, php, mysql_query() function with additional options and abilities. A sample feature would be some handy debugging tools we can turn on/off.

I was wondering how popular query handlers are and what features people like to build into them.

+1  A: 

I use a DBAL like MDB2, Zend_Db or Doctrine for similar reason. Primarily to be able to utilize all the shortcuts it offers, not so much for the fact that it supports different databases.

E.g., old:

<?php
$query  = "SELECT * FROM table";
$result = mysql_query($query);
if (!$result) {
  echo mysql_error();
} else {
  if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_obj($result)) {
      ...
    }
  }
}
?>

Versus (Zend_Db):

<?php
try {
  $result = $db->fetchAll("SELECT * FROM table");
  foreach($result as $row) {
    ...
  }
} catch (Zend_Exception $e) {
  echo $e->getMessage();
}
?>

IMHO, more intuitive.

Till
A: 

We implemented something similar at my office too. It's proven to be an invaluable to tool for the associated handling features it offers. Error tracking, pre-formatted output and it also works as an 'AL' between MsSQL and MySQL.

Aside from the above features I think it'd be cool to have some low-resource intensive performance monitoring or tracking. For larger or more complicated data sets the queries can be quite weighty and being able to monitor that real-time (or post) would be helpful for any optimization needed on larger-scale websites.

Just my two cents.

jerebear