我有一个带有一些"过滤器"的数据库; 即方法调用,并希望能够根据用户输入的内容动态调用它们.
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}
Run Code Online (Sandbox Code Playgroud)
码:
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
}
Run Code Online (Sandbox Code Playgroud)
foreach循环应该是这样的:
$test = $row->filterCountFunction;
$this->{$test}();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2331 次 |
| 最近记录: |