Hello,
I just wish to have confirmation if this snippet of PHP code will actually function properly. It's part of my SqlCommand class, and sort of acts like the SqlCommand in C#.NET.
It should remove a SqlParameter from the Command's internal array of parameters, but I've read somewhere that using a return inside a loop will not always work, so here's the function I wrote.
open for feedback/ suggestions
[PHP]
final public function removeParameter (SqlParameter $parameter) {
for($i = 0; $i < count($this->parameters); $i++) {
if($parameter->equals($this->parameters[$i])) {
unset($this->parameters[$i]);
$this->parameters = array_values($t his->parameters);
return;
}
}
throw new InvalidParamete rException('Par ameter was not found for the Command');
}
[/PHP]
I just wish to have confirmation if this snippet of PHP code will actually function properly. It's part of my SqlCommand class, and sort of acts like the SqlCommand in C#.NET.
It should remove a SqlParameter from the Command's internal array of parameters, but I've read somewhere that using a return inside a loop will not always work, so here's the function I wrote.
open for feedback/ suggestions
[PHP]
final public function removeParameter (SqlParameter $parameter) {
for($i = 0; $i < count($this->parameters); $i++) {
if($parameter->equals($this->parameters[$i])) {
unset($this->parameters[$i]);
$this->parameters = array_values($t his->parameters);
return;
}
}
throw new InvalidParamete rException('Par ameter was not found for the Command');
}
[/PHP]
Comment