Update MySQL PDO Function

Error message

Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; GeSHi has a deprecated constructor in require_once() (line 915 of /home/digipiph/public_html/sites/all/modules/libraries/libraries.module).

Below is a PDO update function that I wrote to save me time from
constantly constructing the PDO update query whenever I need it. Now I
simply pass my values and fields to the function and all is taken care

//START: SQLUpdate
//$fields = array of fields in DB
//$values = array of values respective to the $fields
if (!function_exists("SQLUpdate")) : function
SQLUpdate($table,$fields,$values,$where) {
  //Connect to DB
  //build the field to value correlation
  $buildSQL = '';
  if (is_array($fields)) {
        //loop through all the fields and assign them to the correlating $values
        foreach($fields as $key => $field) :
      if ($key == 0) {
            //first item
            $buildSQL .= $field.' = ?';
          } else {
            //every other item follows with a ","
            $buildSQL .= ', '.$field.' = ?';
  } else {
    //we are only updating one field
        $buildSQL .= $fields.' = :value';
  $prepareUpdate = $db->prepare('UPDATE '.$table.' SET '.$buildSQL.'
WHERE '.$where);
  //execute the update for one or many values
  if (is_array($values)) {
  } else {
        $prepareUpdate->execute(array(':value' => $values));
  //record and print any DB error that may be given
  $error = $prepareUpdate->errorInfo();
  if ($error[1]) print_r($error);
} endif;
//END: SQLUpdate

Here are some examples of how to use it:

//updating one item
SQLUpdate('db_table', 'db_field', 'db_value','id = 1');
//updating multiple items
$fields[] = 'name';
$fields[] = 'description';
$fields[] = 'value';
$fields[] = 'stock';
$values[] = $_POST['name'];
$values[] = $_POST['description'];
$values[] = $_POST['value'];
$values[] = $_POST['stock'];
SQLUpdate('db_table', $fields, $values,'type = "product"');