Invalid argument supplied for foreach(); Array not being set properly
Here is my code:
class Subscriber extends DatabaseObject {
protected static $table_name = "email_list";
protected static $db_fields = array('id', 'email');
public $id;
public $email;
function __construct() {
self::$object = new Subscriber;
}
}
In the parent class, DatabaseObject, is the problem:
class DatabaseObject {
protected static $object;
protected static $db_fields;
protected function attributes() {
$attributes = array();
foreach (self::$db_fields as $field) {
// edited
}
return $attributes;
}
However, I get Warning: Invalid argument supplied for foreach() because of
the line:
foreach (self::$db_fields as $field) {
Why isn't the array being set? I tried setting it in the constructor
manually but it did not work either.
No comments:
Post a Comment