当前位置: 首页>>代码示例>>PHP>>正文


PHP CORE_database::join_fields方法代码示例

本文整理汇总了PHP中CORE_database::join_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP CORE_database::join_fields方法的具体用法?PHP CORE_database::join_fields怎么用?PHP CORE_database::join_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CORE_database的用法示例。


在下文中一共展示了CORE_database::join_fields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: explode


//.........这里部分代码省略.........
             $order_by .= ' ASC';
             $smarty_sort = 'asc=';
         } else {
             if (!eregi('date', $smarty_order)) {
                 $order_by .= ' ASC';
                 $smarty_sort = 'asc=';
             } else {
                 $order_by .= ' DESC';
                 $smarty_sort = 'desc=';
             }
         }
     }
     # generate the full query
     $db =& DB();
     $q = eregi_replace("%%fieldList%%", $field_list, $search->sql);
     $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX . $construct->table, $q);
     $q = eregi_replace("%%whereList%%", "", $q);
     $q .= " site_id = " . $db->qstr(DEFAULT_SITE);
     $q .= $order_by;
     //////////////////
     # echo "<BR> $q <BR>";
     $current_page = 1;
     $offset = -1;
     if (!empty($VAR['page'])) {
         $current_page = $VAR['page'];
     }
     if (empty($search->limit)) {
         $search->limit = 25;
     }
     if ($current_page > 1) {
         $offset = $current_page * $search->limit - $search->limit;
     }
     $result = $db->SelectLimit($q, $search->limit, $offset);
     # error reporting
     if ($result === false) {
         global $C_debug;
         $C_debug->error('charge.inc.php', 'search', $db->ErrorMsg());
         if (isset($this->trigger["{$type}"])) {
             include_once PATH_CORE . 'trigger.inc.php';
             $trigger = new CORE_trigger();
             $trigger->trigger($this->trigger["{$type}"], 0, $VAR);
         }
         return;
     }
     # put the results into a smarty accessable array
     $i = 0;
     $class_name = TRUE;
     while (!$result->EOF) {
         $smart[$i] = $result->fields;
         if ($class_name) {
             $smart[$i]['_C'] = 'row1';
             $class_name = FALSE;
         } else {
             $smart[$i]['_C'] = 'row2';
             $class_name = TRUE;
         }
         $result->MoveNext();
         $i++;
     }
     # get any linked fields
     if ($i > 0) {
         $db_join = new CORE_database();
         $this->result = $db_join->join_fields($smart, $this->linked);
     } else {
         $this->result = $smart;
     }
     # get the result count:
     $results = $result->RecordCount();
     # define the DB vars as a Smarty accessible block
     global $smarty;
     # define the results
     $smarty->assign($this->table, $this->result);
     $smarty->assign('page', $VAR['page']);
     $smarty->assign('order', $smarty_order);
     $smarty->assign('sort', $smarty_sort);
     $smarty->assign('limit', $search->limit);
     $smarty->assign('search_id', $search->id);
     $smarty->assign('results', $search->results);
     # get the total pages for this search:
     if (empty($search->limit)) {
         $this->pages = 1;
     } else {
         $this->pages = intval($search->results / $search->limit);
     }
     if ($search->results % $search->limit) {
         $this->pages++;
     }
     # total pages
     $smarty->assign('pages', $this->pages);
     # current page
     $smarty->assign('page', $current_page);
     $page_arr = '';
     for ($i = 0; $i <= $this->pages; $i++) {
         if ($this->page != $i) {
             $page_arr[] = $i;
         }
     }
     # page array for menu
     $smarty->assign('page_arr', $page_arr);
 }
开发者ID:sluther,项目名称:agilebill,代码行数:101,代码来源:charge.inc.php

示例2: DB

    function this_search_show($VAR, $construct, $type)
    {
        global $VAR;
        # Get the list of parents for this group
        $this->group_parent_list($VAR['module_method_group_id']);
        # generate the full query
        $q = "SELECT * FROM\n\t\t\t  " . AGILE_DB_PREFIX . "module_method\n\t\t\t  WHERE\n\t\t\t  module_id = " . $VAR['module_method_module_id'];
        $db =& DB();
        $result = $db->Execute($q);
        # put the results into a smarty accessable array
        $i = 0;
        $class_name = TRUE;
        while (!$result->EOF) {
            $smart[$i] = $result->fields;
            $method_id = $smart[$i]['id'];
            ## Get the auth status for this method & group
            $q1 = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'group_method WHERE
				method_id = ' . $smart[$i]['id'] . ' AND
				group_id  = ' . $VAR['module_method_group_id'];
            $db1 =& DB();
            $resulta = $db1->Execute($q1);
            #echo "<BR> $q1";
            ## authorized by current group
            if ($resulta->RecordCount() >= 1) {
                #echo "<BR>1 - This group matches!";
                $smart[$i]['checked'] = '1';
            } else {
                # get the parent group id(s) for this group
                $match = false;
                for ($ii = 0; $ii < count($this->group); $ii++) {
                    if ($match == false && $this->group[$ii] != $VAR['module_method_group_id']) {
                        $q2 = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'group_method
								WHERE method_id = ' . $method_id . '
								AND group_id = ' . $this->group[$ii];
                        $db2 =& DB();
                        $resultb = $db2->Execute($q2);
                        #echo "<BR> $q2";
                        if ($resultb->RecordCount() >= 1) {
                            $match = true;
                        }
                    }
                }
                ## authorized by parent
                if ($match) {
                    #echo "<BR>2 - This Parent Matches!";
                    $smart[$i]['checked'] = '2';
                } else {
                    ## not authorized
                    #echo "<BR>3 - NO matches";
                    $smart[$i]['checked'] = '3';
                }
            }
            if ($class_name) {
                $smart[$i]['_C'] = 'row2';
                $class_name = FALSE;
            } else {
                $smart[$i]['_C'] = 'row1';
                $class_name = TRUE;
            }
            $result->MoveNext();
            $i++;
        }
        # get any linked fields
        if ($i > 0) {
            $db_join = new CORE_database();
            $this->result = $db_join->join_fields($smart, $this->linked);
        } else {
            $this->result = $smart;
        }
        # get the result count:
        $results = $result->RecordCount();
        # define the DB vars as a Smarty accessible block
        global $smarty;
        # define the results
        $smarty->assign($construct->table, $this->result);
        $smarty->assign('page', $VAR['page']);
        $smarty->assign('order', 1111);
        $smarty->assign('sort', 1111);
        $smarty->assign('limit', 1111);
        $smarty->assign('search_id', 1111);
        $smarty->assign('results', $results);
        # get the total pages for this search:
        $this->pages = 1;
        if ($search->results % $search->limit) {
            $this->pages++;
        }
        # total pages
        $smarty->assign('pages', $this->pages);
        # current page
        $smarty->assign('page', $current_page);
        $page_arr = '';
        for ($i = 0; $i <= $this->pages; $i++) {
            if ($this->page != $i) {
                $page_arr[] = $i;
            }
        }
        # page array for menu
        $smarty->assign('page_arr', $page_arr);
    }
开发者ID:hbustun,项目名称:agilebill,代码行数:99,代码来源:module_method.inc.php

示例3: CORE_database_search_show


//.........这里部分代码省略.........
    if ($result === false) {
        global $C_debug;
        $C_debug->error('database.inc.php', 'search', $db->ErrorMsg());
        if (isset($construct->trigger["{$type}"])) {
            include_once PATH_CORE . 'trigger.inc.php';
            $trigger = new CORE_trigger();
            $trigger->trigger($construct->trigger["{$type}"], 0, $VAR);
        }
        return;
    }
    ### Put the results into a smarty accessable array
    ### Run any custom validation on this result for
    ### this module
    if (isset($construct->custom_EXP)) {
        $i = 0;
        $class_name = TRUE;
        $results = 0;
        while (!$result->EOF) {
            for ($ei = 0; $ei < count($construct->custom_EXP); $ei++) {
                $field = $construct->custom_EXP[$ei]["field"];
                $value = $construct->custom_EXP[$ei]["value"];
                if ($result->fields["{$field}"] == $value) {
                    $smart[$i] = $result->fields;
                    if ($class_name) {
                        $smart[$i]['_C'] = 'row1';
                        $class_name = FALSE;
                    } else {
                        $smart[$i]['_C'] = 'row2';
                        $class_name = TRUE;
                    }
                    $i++;
                    $ei = count($construct->custom_EXP);
                    $results++;
                }
            }
            $result->MoveNext();
        }
    } else {
        $i = 0;
        $class_name = TRUE;
        while (!$result->EOF) {
            $smart[$i] = $result->fields;
            if ($class_name) {
                $smart[$i]['_C'] = 'row1';
                $class_name = FALSE;
            } else {
                $smart[$i]['_C'] = 'row2';
                $class_name = TRUE;
            }
            $result->MoveNext();
            $i++;
        }
    }
    # get any linked fields
    if ($i > 0) {
        $db_join = new CORE_database();
        $construct->result = $db_join->join_fields($smart, $construct->linked);
    } else {
        $construct->result = $smart;
    }
    # get the result count:
    $results = $result->RecordCount();
    # define the DB vars as a Smarty accessible block
    global $smarty;
    # define the results
    $smarty->assign($construct->table, $construct->result);
    $smarty->assign('page', $VAR['page']);
    $smarty->assign('order', $smarty_order);
    $smarty->assign('sort', $smarty_sort);
    $smarty->assign('limit', $search->limit);
    $smarty->assign('search_id', $search->id);
    $smarty->assign('results', $search->results);
    # get the total pages for this search:
    if (empty($search->limit)) {
        $construct->pages = 1;
    } else {
        $construct->pages = intval($search->results / $search->limit);
    }
    if ($search->results % $search->limit) {
        $construct->pages++;
    }
    # total pages
    $smarty->assign('pages', $construct->pages);
    # current page
    $smarty->assign('page', $current_page);
    $page_arr = '';
    for ($i = 0; $i <= $construct->pages; $i++) {
        if ($construct->page != $i) {
            $page_arr[] = $i;
        }
    }
    # page array for menu
    $smarty->assign('page_arr', $page_arr);
    if (isset($construct->trigger["{$type}"])) {
        include_once PATH_CORE . 'trigger.inc.php';
        $trigger = new CORE_trigger();
        $trigger->trigger($construct->trigger["{$type}"], 1, $VAR);
    }
    return $construct->result;
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:database_search_show.inc.php

示例4: while

 function search_xml($VAR, $construct, $type)
 {
     /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/
     # set the field list for this method:
     $arr = $construct->method["{$type}"];
     # loop through the field list to create the sql queries
     $arr = $construct->method[$type];
     $field_list = '';
     $i = 0;
     while (list($key, $value) = each($arr)) {
         if ($i == 0) {
             $field_var = $construct->table . '_' . $value;
             $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value;
             // determine if this record is linked to another table/field
             if ($construct->field[$value]["asso_table"] != "") {
                 $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]);
             }
         } else {
             $field_var = $construct->table . '_' . $value;
             $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value;
             // determine if this record is linked to another table/field
             if ($construct->field[$value]["asso_table"] != "") {
                 $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]);
             }
         }
         $i++;
     }
     # get the search details:
     if (isset($VAR['search_id'])) {
         include_once PATH_CORE . 'search.inc.php';
         $search = new CORE_search();
         $search->get($VAR['search_id']);
     } else {
         echo '<BR> The search terms submitted were invalid!';
     }
     # get the sort order details:
     if (isset($VAR['order_by']) && $VAR['order_by'] != "") {
         $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by'];
         $smarty_order = $VAR['order_by'];
     } else {
         $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by;
         $smarty_order = $search->order_by;
     }
     # format saved search string
     $sql = explode(" WHERE ", $search->sql);
     # generate the full query
     $q = preg_replace("/%%fieldList%%/i", $field_list, $search->sql);
     $q = preg_replace("/%%tableList%%/i", AGILE_DB_PREFIX . $construct->table, $q);
     $q = preg_replace("/%%whereList%%/i", "", $q);
     $q .= " " . AGILE_DB_PREFIX . $construct->table . ".site_id = '" . DEFAULT_SITE . "'";
     $q .= $order_by;
     $db =& DB();
     $result = $db->Execute($q);
     # error reporting
     if ($result === false) {
         global $C_debug;
         $C_debug->error('core:export.inc.php', 'search_xml', $db->ErrorMsg() . '<br><br>' . $q);
         echo "An SQL error has occured!";
         return;
     }
     # put the results into an array
     $i = 0;
     $class_name = TRUE;
     $results = '';
     while (!$result->EOF) {
         $results[$i] = $result->fields;
         $result->MoveNext();
         $i++;
     }
     # get any linked fields
     if ($i > 0) {
         $this->result = $results;
         $db_join = new CORE_database();
         $this->result = $db_join->join_fields($results, $this->linked);
     } else {
         $this->result = $results;
     }
     /************** END STANDARD EXPORT SEARCH CODE *********************/
     # create the xml processing instruction
     # header("Content-type: text/xml");
     $filename = 'XML_Export.xml';
     # determine what action to take:
     if ($VAR["type"] == "display") {
         header('Content-type: application/x-xml');
         header("Content-Disposition: inline; filename={$filename}");
     } else {
         if ($VAR["type"] == "download") {
             header("Content-Disposition: attachment; filename={$filename}");
         }
     }
     $_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
     $_xml .= "<results>\r\n";
     # loop through the resulsts and display as PDF
     $row = 0;
     for ($ii = 0; $ii < count($this->result); $ii++) {
         $_xml .= "\t<" . $construct->table . ">\r\n";
         # get the data for each cell:
         reset($arr);
         $column = 0;
         while (list($key, $value) = each($arr)) {
//.........这里部分代码省略.........
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:export.inc.php


注:本文中的CORE_database::join_fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。