QuickBooks/Driver/Sql.php
protected function _configWrite($user, $module, $key, $value, $type, $opts)
	{
		$errnum = 0;
		$errmsg = '';

		if ($arr = $this->_fetch($this->_query("
			SELECT
				quickbooks_config_id
			FROM
				" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
			WHERE
				qb_username = '" . $this->_escape($user) . "' AND
				module = '" . $this->_escape($module) . "' AND
				cfgkey = '" . $this->_escape($key) . "' ", $errnum, $errmsg, 0, 1)))
		{
			$this->_query("
				UPDATE
					" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
				SET
					cfgval = '" . $this->_escape($value) . "',
					mod_datetime = '" . date('Y-m-d H:i:s') . "'
				WHERE
					quickbooks_config_id = " . $arr['quickbooks_config_id'], $errnum, $errmsg);
		}
		else
		{
			return $this->_query("
				INSERT INTO
					" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
				(
					qb_username,
					module,
					cfgkey,
					cfgval,
					cfgtype,
					cfgopts,
					write_datetime,
					mod_datetime
				) VALUES (
					'" . $this->_escape($user) . "',
					'" . $this->_escape($module) . "',
					'" . $this->_escape($key) . "',
					'" . $this->_escape($value) . "',
					'" . $this->_escape($type) . "',
					'" . $this->_escape(serialize($opts)) . "',
					'" . date('Y-m-d H:i:s') . "',
					'" . date('Y-m-d H:i:s') . "'
				) ", $errnum, $errmsg);
		}
	}
protected function _configWrite($user, $module, $key, $value, $type, $opts)
	{
		$errnum = 0;
		$errmsg = '';

		if ($arr = $this->_fetch($this->_query("
			SELECT
				quickbooks_config_id
			FROM
				" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
			WHERE
				qb_username = '" . $this->_escape($user) . "' AND
				module = '" . $this->_escape($module) . "' AND
				cfgkey = '" . $this->_escape($key) . "' ", $errnum, $errmsg, 0, 1)))
		{
			$this->_query("
				UPDATE
					" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
				SET
					cfgval = '" . $this->_escape($value) . "',
					mod_datetime = '" . date('Y-m-d H:i:s') . "'
				WHERE
					quickbooks_config_id = " . $arr['quickbooks_config_id'], $errnum, $errmsg);
		}
		else
		{
			return $this->_query("
				INSERT INTO
					" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
				(
					qb_username,
					module,
					cfgkey,
					cfgval,
					cfgtype,
					cfgopts,
					write_datetime,
					mod_datetime
				) VALUES (
					'" . $this->_escape($user) . "',
					'" . $this->_escape($module) . "',
					'" . $this->_escape($key) . "',
					'" . $this->_escape($value) . "',
					'" . $this->_escape($type) . "',
					'" . $this->_escape(serialize($opts)) . "',
					'" . date('Y-m-d H:i:s') . "',
					'" . date('Y-m-d H:i:s') . "'
				) ", $errnum, $errmsg);
		}
	}
Write a configuration variable to the database

@param string $user		The QuickBooks user this is stored for
@param string $module	The module name this is stored for (free-form text, you make it up, but make it unique! a good habit is to use the __CLASS__ constant)
@param string $key		A key to fetch and store this value by
@param mixed $value		The value
@param string $type
@param array $opts
@return boolean			Success or failure