Hi,
I have a class which inserts a row into a database. The values come from an associative array passed as an arguement to a method in the class.
Should i assign the elements of the array as properties to the class before using them in the query or is it ok to just use them directly in the query.
For instance, should i do this:
[CODE]class Database{
public function insertRow($array){
$this->item1 = $array[0];
$this->item2 = $array[1];
$sql = “INSERT INTO table VALUES ($this->item1, $this->item2) WHERE id = 1”;
}
}
..or is it ok to just do this:
[CODE]class Database{
public function insertRow($array){
$sql = “INSERT INTO table VALUES ($array[0], $array[1]) WHERE id = 1”;
}
}
..just looking for best practice advice and pros/cons
Thanks