system/Database/BaseConnection.php
public function prepare(\Closure $func, array $options = [])
	{
		if (empty($this->connID))
		{
			$this->initialize();
		}

		$this->pretend(true);

		$sql = $func($this);

		$this->pretend(false);

		if ($sql instanceof QueryInterface)
		{
			$sql = $sql->getOriginalQuery();
		}

		$class = str_ireplace('Connection', 'PreparedQuery', get_class($this));
		/**
		 * @var BasePreparedQuery $class
		 */
		$class = new $class($this);

		return $class->prepare($sql, $options);
	}
public function prepare(\Closure $func, array $options = [])
	{
		if (empty($this->connID))
		{
			$this->initialize();
		}

		$this->pretend(true);

		$sql = $func($this);

		$this->pretend(false);

		if ($sql instanceof QueryInterface)
		{
			$sql = $sql->getOriginalQuery();
		}

		$class = str_ireplace('Connection', 'PreparedQuery', get_class($this));
		/**
		 * @var BasePreparedQuery $class
		 */
		$class = new $class($this);

		return $class->prepare($sql, $options);
	}
Creates a prepared statement with the database that can then
be used to execute multiple statements against. Within the
closure, you would build the query in any normal way, though
the Query Builder is the expected manner.

Example:
$stmt = $db->prepare(function($db)
{
return $db->table('users')
->where('id', 1)
->get();
})

@param \Closure $func
@param array    $options Passed to the prepare() method

@return BasePreparedQuery|null