Check out my code for AN EMPTY ARRAY. Can someone tell me why this array is empty and not populated from AccountModelwhen executing the following code
$accountModel->setEmail('test@test.com');
class AccountModel extends Model {
protected $table = 'account',
$key = 'id',
$data = array(
'id' => null,
'email' => null,
'first_name' => null,
'created' => null,
'last_login' => null,
'hash' => null
);
}
class Model extends CI_Model {
protected $table = null;
protected $key = null;
protected $connection = null;
protected $data = array();
public function __call ($function, $arguments) {
$original = $function;
$function = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $function));
$prefix = substr($function, 0, 4);
if ($prefix == 'get_' || $prefix == 'set_') {
$key = substr($function, 4);
var_dump($this->data);
exit($key);
}
throw new Exception('Call to undefined method '.get_class($this).'::'.$original.'()');
}
}
According to example 2 on PHP.net, it should work fine.
I am trying to run $ accountModel-> setEmail (' test@test.com ');
update: I understood one more error in my code, for my part it didn’t work. Thanks for helping the guys
source
share