Home  >  Article  >  Backend Development  >  Method of CI mapping (loading) data to the view layer, ciview_PHP tutorial

Method of CI mapping (loading) data to the view layer, ciview_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:55:07924browse

The method of CI mapping (loading) data to the view layer, ciview

The example in this article describes the method of CI mapping (loading) data to the view layer. Share it with everyone for your reference, the details are as follows:

There is a disgusting thing about CI, that is, all data needs to be put into the $data array before it can be mapped to the view layer, such as:

The data method I currently search from the link table (friendly link table, field: id name url) of the database:

$query = $this->db->query("select id,name,url from cg_link where 1");
$links = $query->result();
//这里的$links是不能直接传输入view层的.对错比较
//错误的传输(映射方式):
//$this->load->view('link',$links);
//正确的传输(映射方式):
$data['links'] = $links;
$this->load->view('link',$data);

So any data transmission must be placed in $data. If you want to query a piece of data or a one-dimensional array, use the following function

$sql = "select id,name,url from cg_link where id=21 limit 1";
$query = $this->db->query($sql);
$one = $query->row();//这里是一条数据,获取方式,$one->name;

Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php date and time usage summary", "php object-oriented program" Design introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

Articles you may be interested in:

  • The reasons and solutions for failure to load css and js files in the php ci framework
  • The solution to the error when the CI framework automatically loads the session
  • Solution to the failure to load css and js files in the php ci framework
  • CodeIgniter configuration autoload.php automatic loading usage analysis
  • CodeIgniter implements loading of multiple views at one time Methods
  • The method of displaying array data by looping in view in codeigniter
  • CodeIgniter’s method of connecting, configuring and using the database
  • Codeigniter’s method of detecting form post data
  • Database configuration using codeigniter under Sina SAE cloud platform
  • Summary of codeigniter database operation functions
  • Instructions for using codeigniter’s own database class
  • codeigniter framework batch insert data

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1117093.htmlTechArticleCI mapping (loading) data to the view layer method, ciview This article describes the example of CI mapping (loading) data to View layer methods. Share it with everyone for your reference, the details are as follows: CI has a disgusting...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn