0

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.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Travis
  • 848
  • 1
  • 7
  • 10

2 Answers2

1

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
  • 22,236
  • 4
  • 59
  • 89
0

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
  • 6,503
  • 4
  • 31
  • 38