CI ing (loading) data to the view layer _ php instance

Source: Internet
Author: User
This article mainly introduces how to map (load) data to the view layer by CI, and analyzes the principles and correct usage of CI ing to load data to the view layer by using examples, for more information about how to map (load) data to the view layer, see the example in this article. We will share this with you for your reference. The details are as follows:

CI has a disgusting thing, that is, it needs to put all the data into the $ data array to map to the view layer, such:

Currently, the link Table (link Table, field: id name url) in the database is searched for as follows:

$ Query = $ this-> db-> query ("select id, name, url from cg_link where 1"); $ links = $ query-> result (); // $ links cannot be directly transmitted to the view layer. comparison of errors // transmission of errors (ing mode): // $ this-> load-> view ('link', $ links); // correct transmission (ing mode): $ data ['link'] = $ links; $ this-> load-> view ('link', $ data );

Therefore, as long as the data is transmitted, it must be put into $ data. to query a data or 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, obtaining method, $ one-> name;

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.