/**
  * Writes an array of key/value pairs to the database, where the keys are the
  * database field names and values are what to put in those fields.
  *
  * @param array $fields
  * @return bool
  */
 public function write($fields)
 {
     /**
      * If the field defaults for 'message' and 'level' have been changed
      * in the options, replace the keys in the $field array.
      */
     if ($this->_options['fieldMessage'] != 'message') {
         $fields[$this->_options['fieldMessage']] = $fields['message'];
         unset($fields['message']);
     }
     if ($this->_options['fieldLevel'] != 'level') {
         $fields[$this->_options['fieldLevel']] = $fields['level'];
         unset($fields['level']);
     }
     /**
      * Build an array of field names and values for the SQL statement.
      */
     $fieldNames = array();
     foreach ($fields as $key => &$value) {
         /**
          * @todo needs to be updated for new database adapters
          */
         $fieldNames[] = "`" . $this->_dbAdapter->quote($key) . "`";
         $value = "'" . $this->_dbAdapter->quote($value) . "'";
         if ($value == "''") {
             $value = "NULL";
         }
     }
     /**
      * INSERT the log line into the database.  XXX Replace with Prepared Statement
      */
     /**
      * @todo needs to be updated for new database adapters
      */
     $sql = "INSERT INTO `" . $this->_dbAdapter->quote($this->_tableName) . "` (" . implode(', ', $fieldNames) . ') VALUES (' . implode(', ', $fields) . ')';
     // The database adapter will raise an exception if any problems occur.
     /**
      * @todo needs to be updated for new database adapters
      */
     $this->_dbAdapter->insert($sql);
     return true;
 }