Model view controller 通过MVC-Joomla传递表单数据
我正在创建一个搜索表单,根据名字和姓氏以及成员ID的精确匹配来显示单个用户。我在“com_medsearch/controllers/search.php”中将表单数据设置为自定义控制器。我已经阅读了Joomla文档中的教程,但我不确定如何将数据传递到模型(com_medsearch/models/search.php),并将查询结果返回到同一视图。答案?您可以通过两种方式完成:Model view controller 通过MVC-Joomla传递表单数据,model-view-controller,joomla,components,Model View Controller,Joomla,Components,我正在创建一个搜索表单,根据名字和姓氏以及成员ID的精确匹配来显示单个用户。我在“com_medsearch/controllers/search.php”中将表单数据设置为自定义控制器。我已经阅读了Joomla文档中的教程,但我不确定如何将数据传递到模型(com_medsearch/models/search.php),并将查询结果返回到同一视图。答案?您可以通过两种方式完成: 检测到控制器中有一个搜索帖子,然后调用模型,在模型中可以使用JRequest::getVar/getInt/etc读
$settings = JRequest::get( 'POST' );
$model = & $this->getModel('settings');
$model->saveSettings($settings);
然后在模型中,您可以访问post变量,如:
$settings->input_name
谢谢,但这并没有真正告诉我如何将数据获取到视图中。我不想保存到数据库。我需要通过控制器将数据发送到模型,查询数据库,然后能够从视图中获取结果。