CI Mapping (loading) data to the view layer method, Ciview
The examples in this paper describe the method of CI mapping (loading) data to the view layer. Share to everyone for your reference, as follows:
CI has a disgusting thing, it is necessary to put all the data into the $data array in order to map to the view layer, such as:
Currently I search out the data mode from the link table of the Database (Link table, field: id name URL):
$query = $this->db->query ("Select Id,name,url from Cg_link where 1"); $links = $query->result ();//Here's $ Links cannot be transferred directly into the view layer. Error//Wrong transmission (mapping mode)://$this->load->view (' link ', $links);//correct transmission (map mode): $data [' links '] = $ Links; $this->load->view (' link ', $data);
So as long as the data transfer must be put into the $data, if you want to query a 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 () ;//Here is a piece of data, get the way, $one->name;
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
Articles you may be interested in:
- Reasons and solutions to the failure of loading CSS and JS files in the PHP CI framework
- CI Framework Auto-loading session error solving method
- PHP CI framework for loading CSS and JS file failure solution
- autoload.php Automatic load usage analysis of CodeIgniter configuration
- A method for loading multiple view at once in CodeIgniter
- CodeIgniter view method for displaying array data in a loop
- CodeIgniter How to connect, configure and use database
- CodeIgniter method for detecting form post data
- Database configuration using CodeIgniter under the Sina SAE cloud Platform
- CodeIgniter Database Operation Function Summary
- CodeIgniter How to use the database class
- CodeIgniter Framework BULK INSERT data
http://www.bkjia.com/PHPjc/1117093.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117093.html techarticle CI Mapping (loading) data to the view layer method, Ciview This article describes the CI mapping (loading) data to the view layer method. Share to everyone for your reference, specifically as follows: CI has a disgusting ...