Hi all,
I want to automate things a bit and dynamically assign database-values to an associative array in a class-object.
$db = $sql->arrays("SELECT * FROM $type WHERE id='32');
//query the DB with mysql_fetch_array() to retrieve values
foreach ($db as $key=>$value)
// assigns the values to the corresponding object->method['array'] - ['array'] corresponds to the column-name in the database
{
if (is_string($key))
{
$this->$type=array($key=>$value);
}
}
'$type' in '$this->$type' can only be of four different values, each of which is defined in the class-constructor as array.
The problem is: it doesn't work.
Does anyone know a solution to this?