如何通过从视图中的数据在codeigniter模型 [英] how to pass data from view to model in codeigniter

查看:231
本文介绍了如何通过从视图中的数据在codeigniter模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发与codeigniter系统,在我的情况,我必须preSS在一个用户界面中的链接,并得到它的ID,并把它传递给模型,并得到有关该ID的数据和转到其他界面,并在相关领域的显示数据,我知道如何从模型查看传递数据,但我不知道如何通过从视图模型,你们可以帮帮我吗?

I'm developing a system with codeigniter, in my situation i have to press a link in one user interface and get it's ID and pass it to the model and get the data relevant to that ID and go to the other interface and display the data in the relevant fields, i know how to pass data from model to view, but i don't know how to pass to model from the view, can you guys please help me?

(这是我的第一个CI项目)

(this is my first CI project)

问候, Rangana

regards, Rangana

推荐答案

您可以通过多种不同的方式在页面之间的信息......在这里有一个例子:

You can pass information between pages in several different ways... here's an example:

您的链接: http://example.com/controller/method/id/15

$uri = $this->uri->uri_to_assoc();
$this->load->model('model');
$this->model->handleInput($uri['id']);

以上code将通过ID在URL中的模型法handleInput。比方说,你的URL看起来像这样: http://example.com/controller/method/15 - 假定ID段中的URL总是在同一个地方,也就是,在控制器和方法后,可以检索这样的:

The above code will pass the id in the URL to the model method handleInput. Let's say your URL looks like this: http://example.com/controller/method/15 - assuming the ID segment in the URL is always in the same place, that is, after the controller and the method, you can retrieve it like this:

$id = $this->uri->segment(3);
$this->load->model('model');
$this->model->handleInput($id);

您还可以通过使用POST方法的数据。您可以使用该功能后,这样的检索安全后值:

You can also pass data using the post method. You can retrieve safe post values using the post function, like this:

$id = $this->input->post('id');
$this->load->model('model');
$this->model->handleInput($id);

这篇关于如何通过从视图中的数据在codeigniter模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆