CI Mapping (loading) data to the view layer method, ciview_php tutorial

Source: Internet
Author: User
Tags bulk insert form post getting started with php codeigniter

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.