A database connection problem in onethink

Source: Internet
Author: User
Onethink AdminArticlegetDocumentList () method; I directly pasted the code {code ...} {code ...} this link cannot be understood. Can someone explain it to me? & #039 ;__ DOCUMENT _ & #039 ;. strtoupper ($ modelName) represents another model. & #039 ;__... the Admin/Article/getDocumentList () method of onethink;
I directly pasted the code.

Protected function getDocumentList ($ cate_id = 0, $ model_id = null, $ position = null, $ field = true, $ group_id = null) {/* query condition initialization */$ map = array (); if (isset ($ _ GET ['title']) {$ map ['title'] = array ('like', '% '. (string) I ('title '). '%');} if (isset ($ _ GET ['status']) {$ map ['status'] = I ('status '); $ status = $ map ['status'];} else {$ status = null; $ map ['status'] = array ('in', '0, 1, 2 ');} if (isset ($ _ GET ['start']) {$ Map ['Update _ time'] [] = array ('egt', strtotime (I ('start ')));} if (isset ($ _ GET ['end']) {$ map ['Update _ time'] [] = array ('elt ', 24*60*60 + strtotime (I ('end');} if (isset ($ _ GET ['nickname']) {$ map ['uid'] = M ('member')-> where (array ('nickname' => I ('nickname '))) -> getField ('uid');} if (! Is_administrator (UID) {$ map ["uid"] = UID;} // construct list data $ Document = M ('document'); if ($ cate_id) {$ map ['category _ id'] = $ cate_id;} $ map ['pid '] = I ('pid', 0 ); if ($ map ['pid ']) {// The Sub-document list ignores the category unset ($ map ['category _ id']);} $ Document-> alias ('document'); if (! Is_null ($ model_id) {$ map ['model _ id'] = $ model_id; if (is_array ($ field) & array_diff ($ Document-> getDbFields (), $ field) {$ modelName = M ('model')-> getFieldById ($ model_id, 'name'); $ Document-> join ('_ DOCUMENT _'. strtoupper ($ modelName ). '__'. $ modelName. 'on document. id = '. $ modelName. '. id'); $ key = array_search ('id', $ field); if (false! ==$ Key) {unset ($ field [$ key]); $ field [] = 'document. id' ;}} if (! Is_null ($ position) {$ map [] = "position & {$ position }={ $ position}";} if (! Is_null ($ group_id) {$ map ['group _ id'] = $ group_id;} $ list = $ this-> lists ($ Document, $ map, 'level DESC, DOCUMENT. id DESC ', $ field); if ($ map ['pid']) {// obtain the superior Document $ article = $ Document-> field ('Id, title, type ')-> find ($ map ['pid']); $ this-> assign ('Article', $ article );} // check whether the specified category allows content to be published. $ allow_publish = get_category ($ cate_id, 'Allow _ publish '); $ this-> assign ('status', $ status ); $ this-> assign ('allow', $ allow_publish); $ this-> assign ('pid ', $ map ['pid']); $ this-> meta_title = 'document list'; return $ list ;}

Where

$Document->join('__DOCUMENT_'.strtoupper($modelName).'__ '.$modelName.' ON DOCUMENT.id='.$modelName.'.id');

This link cannot be understood. Can someone help me explain it? I know.'__DOCUMENT_'.strtoupper($modelName)Represents another model.'__ '.$modelName.'This is useless.

Reply content:

The Admin/Article/getDocumentList () method of onethink;
I directly pasted the code.

Protected function getDocumentList ($ cate_id = 0, $ model_id = null, $ position = null, $ field = true, $ group_id = null) {/* query condition initialization */$ map = array (); if (isset ($ _ GET ['title']) {$ map ['title'] = array ('like', '% '. (string) I ('title '). '%');} if (isset ($ _ GET ['status']) {$ map ['status'] = I ('status '); $ status = $ map ['status'];} else {$ status = null; $ map ['status'] = array ('in', '0, 1, 2 ');} if (isset ($ _ GET ['start']) {$ Map ['Update _ time'] [] = array ('egt', strtotime (I ('start ')));} if (isset ($ _ GET ['end']) {$ map ['Update _ time'] [] = array ('elt ', 24*60*60 + strtotime (I ('end');} if (isset ($ _ GET ['nickname']) {$ map ['uid'] = M ('member')-> where (array ('nickname' => I ('nickname '))) -> getField ('uid');} if (! Is_administrator (UID) {$ map ["uid"] = UID;} // construct list data $ Document = M ('document'); if ($ cate_id) {$ map ['category _ id'] = $ cate_id;} $ map ['pid '] = I ('pid', 0 ); if ($ map ['pid ']) {// The Sub-document list ignores the category unset ($ map ['category _ id']);} $ Document-> alias ('document'); if (! Is_null ($ model_id) {$ map ['model _ id'] = $ model_id; if (is_array ($ field) & array_diff ($ Document-> getDbFields (), $ field) {$ modelName = M ('model')-> getFieldById ($ model_id, 'name'); $ Document-> join ('_ DOCUMENT _'. strtoupper ($ modelName ). '__'. $ modelName. 'on document. id = '. $ modelName. '. id'); $ key = array_search ('id', $ field); if (false! ==$ Key) {unset ($ field [$ key]); $ field [] = 'document. id' ;}} if (! Is_null ($ position) {$ map [] = "position & {$ position }={ $ position}";} if (! Is_null ($ group_id) {$ map ['group _ id'] = $ group_id;} $ list = $ this-> lists ($ Document, $ map, 'level DESC, DOCUMENT. id DESC ', $ field); if ($ map ['pid']) {// obtain the superior Document $ article = $ Document-> field ('Id, title, type ')-> find ($ map ['pid']); $ this-> assign ('Article', $ article );} // check whether the specified category allows content to be published. $ allow_publish = get_category ($ cate_id, 'Allow _ publish '); $ this-> assign ('status', $ status ); $ this-> assign ('allow', $ allow_publish); $ this-> assign ('pid ', $ map ['pid']); $ this-> meta_title = 'document list'; return $ list ;}

Where

$Document->join('__DOCUMENT_'.strtoupper($modelName).'__ '.$modelName.' ON DOCUMENT.id='.$modelName.'.id');

This link cannot be understood. Can someone help me explain it? I know.'__DOCUMENT_'.strtoupper($modelName)Represents another model.'__ '.$modelName.'This is useless.

The alias is equivalent

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.