public function namedParameter($Name, $CreateNew = false, $Value = null)
{
// Format the parameter name so it is safe for sql
$NiceName = ':' . preg_replace('/([^\\w])/', '', $Name);
// Removes everything from the string except letters, numbers and underscores
if ($CreateNew) {
// Make sure that the new name doesn't already exist.
$NumberedName = $NiceName;
$i = 0;
while (array_key_exists($NumberedName, $this->_NamedParameters)) {
$NumberedName = $NiceName . $i;
++$i;
}
$NiceName = $NumberedName;
}
if (!is_null($Value)) {
$this->_NamedParameters[$NiceName] = $Value;
}
return $NiceName;
}