static function embedParams($string, $params, DABLPDO $conn = null) {
		if (null != $conn) {
			$params = $conn->prepareInput($params);
		} else {
			foreach($params as &$value) {
				if (is_int($value)) {
					continue;
				} elseif (is_bool($value)) {
					$value = $value ? 1 : 0;
				} elseif (is_null($value)) {
					$value = 'NULL';
				} else {
					$value = "'{$value}'";
				}
			}
		}

		// escape % by making it %%
		$string = str_replace('%', '%%', $string);

		// replace ? with %s
		$string = str_replace(self::PARAM, '%s', $string);

		// add $query to the beginning of the array
		array_unshift($params, $string);

		if (!($string = @call_user_func_array('sprintf', $params))) {
			throw new RuntimeException('Could not insert parameters into query string. The number of ?s might not match the number of parameters.');
		}
		return $string;
	}