core-bundle/src/Resources/contao/library/Contao/Database/Statement.php
public function set($arrParams)
	{
		$strQuery = '';
		$arrParams = $this->escapeParams($arrParams);

		// INSERT
		if (strncasecmp($this->strQuery, 'INSERT', 6) === 0)
		{
			$strQuery = sprintf('(%s) VALUES (%s)',
								implode(', ', array_map('Database::quoteIdentifier', array_keys($arrParams))),
								str_replace('%', '%%', implode(', ', $arrParams)));
		}

		// UPDATE
		elseif (strncasecmp($this->strQuery, 'UPDATE', 6) === 0)
		{
			$arrSet = array();

			foreach ($arrParams as $k=>$v)
			{
				$arrSet[] = Database::quoteIdentifier($k) . '=' . $v;
			}

			$strQuery = 'SET ' . str_replace('%', '%%', implode(', ', $arrSet));
		}

		$this->strQuery = str_replace('%p', $strQuery, $this->strQuery);

		return $this;
	}
public function set($arrParams)
	{
		$strQuery = '';
		$arrParams = $this->escapeParams($arrParams);

		// INSERT
		if (strncasecmp($this->strQuery, 'INSERT', 6) === 0)
		{
			$strQuery = sprintf('(%s) VALUES (%s)',
								implode(', ', array_map('Database::quoteIdentifier', array_keys($arrParams))),
								str_replace('%', '%%', implode(', ', $arrParams)));
		}

		// UPDATE
		elseif (strncasecmp($this->strQuery, 'UPDATE', 6) === 0)
		{
			$arrSet = array();

			foreach ($arrParams as $k=>$v)
			{
				$arrSet[] = Database::quoteIdentifier($k) . '=' . $v;
			}

			$strQuery = 'SET ' . str_replace('%', '%%', implode(', ', $arrSet));
		}

		$this->strQuery = str_replace('%p', $strQuery, $this->strQuery);

		return $this;
	}
Autogenerate the SET/VALUES subpart of a query from an associative array

Usage:

$set = array(
'firstname' => 'Leo',
'lastname'  => 'Feyer'
);
$stmt->prepare("UPDATE tl_member %s")->set($set);

@param array $arrParams The associative array

@return Statement The statement object