我有一个带有一些“过滤器”的数据库;即方法调用,并希望能够根据用户输入的内容动态调用它们。
Code Igniter 似乎不喜欢这样,有什么想法吗?它输出: 在 GetEmailCountfilter_male_count() 中:
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined property: Targeted_Email::$filter_male_count()</p>
<p>Filename: core/Model.php</p>
<p>Line Number: 51</p>
{"emailCount":null}
代码:
public function getEmailCount($filter){
echo 'In GetEmailCount';
$result = array();
$query = $this->db->get('base_targeted_email_filters');
foreach ($query->result() as $row){
if($filter == $row->name){
$test = $row->filterCountFunction . "()";
echo $test;
$result['emailCount'] = $this->{$test};
}
return $result
}