public function update($table, $object, $where = array(), $resync = true, $discov = null, $derive = true)	// @todo Is that the correct default for $derive?
	{
		$sql = '';
		$set = array();

		if (is_object($object))
		{
			$object = $object->asArray();
		}

		$avail = $this->fields($table, true);		// List of available fields

		// Case folding support
		if ($this->foldsToLower())
		{
			$object = array_change_key_case($object, CASE_LOWER);
		}
		else if ($this->foldsToUpper())
		{
			$object = array_change_key_case($object, CASE_UPPER);
		}

		// Merge by keys to make sure we don't INSERT any fields that don't exist in this schema
		$object = array_intersect_key($object, $avail);

		//
		foreach ($object as $field => $value)
		{
			// Commented out because doing this to very large integers (i.e. ItemRef/FullName is a large integer SKU) causes integer overflow
			/*if (strlen((int) $value) == strlen($value))
			{
				$set[] = $field . ' = ' . (int) $value;
			}
			else
			{*/
			//	$set[] = $field . " = '" . $this->_escape($value) . "' ";
			//}

			if (is_null($value))
			{
				$set[] = $field . " = NULL ";
			}
			else
			{
				$set[] = $field . " = '" . $this->_escape($value) . "' ";
			}
		}

		$wheres = array();
		foreach ($where as $part)
		{
			foreach ($part as $field => $value)
			{
				$wheres[] = $field . " = '" . $this->_escape($value) . "' ";
			}
		}

		$sql = "UPDATE " . $this->_escape($table) . " SET " . implode(', ', $set);

		if ($resync)
		{
			$sql .= ", " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . " = '" . date('Y-m-d H:i:s') . "' ";
		}

		$sql .= " WHERE " . implode(' AND ', $wheres);

		//print($sql);

		$errnum = 0;
		$errmsg = '';
		$return = $this->_query($sql, $errnum, $errmsg);

		if (is_null($discov))
		{
			$discov = $resync;
		}

		if ($discov)
		{
			// Update the discover datetime *IF THE DISCOVER DATETIME IS NULL*
			//	This happens when an AddResponse is received, and we need to
			//	update a record that has just been added to QuickBooks. If we
			//	don't mark it as discovered, then updates to the record will
			//	never be picked up and sent to QuickBooks

			$errnum = 0;
			$errmsg = '';

			$wheres[] = QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " IS NULL ";

			$this->_query("
				UPDATE
					" . $this->_escape($table) . "
				SET
					" . QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " = " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . "
				WHERE
					" . implode(' AND ', $wheres), $errnum, $errmsg);
		}

		return $return;
	}