简体   繁体   English

在Codeigniter 1.7.2中将数据从模型发送到控制器

[英]sending data from model to controller in codeigniter 1.7.2

I am receiving $fb_data[uid] ie Facebook UID from my model and I want to put this variable's value into my controller where the signup process is taking place passing fields in controller like this: 我从模型中收到$fb_data[uid]即Facebook UID,我想将此变量的值放入控制器,在控制器中进行注册过程,传递控制器中的字段,如下所示:

$sql_data = array('student_fname' => $student_fname, 'student_sname' => $student_sname, 'student_org' => $student_org, 'student_title' => $student_title, 'student_uid' => ?

I am confused how to insert the Facebook UID value here at my controller.. 我很困惑如何在我的控制器上在这里插入Facebook UID值。

You need to have a function in your model which returns your $fb_data . 您需要在模型中有一个函数,该函数返回$fb_data In the controller you have (if not already done) to load the model 在控制器中,您(如果尚未完成)可以加载模型

$this->load->model('model_name');

Then you can access your model function from the controller by calling 然后,您可以通过调用从控制器访问模型函数

$this->model_name->function_name();

The section 'loading a model' in the CI documentation explains it again. CI文档中的“加载模型”部分再次说明了这一点。

Do like this : 这样做:

First create one method in controller : 首先在controller中创建一个方法:

Ex : In controller 例如:在控制器中

function fbcontent() {
$this->load->model('your model name');
$content = $this->model_name->fbaction();
}

and In model 和模型

function fbaction(){
$sql_data = array('student_fname' => $student_fname, 'student_sname' => $student_sname, 'student_org' => $student_org, 'student_title' => $student_title, 'student_uid' => ?
return $sql_data;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM