PHP list Read field information once ____php

Source: Internet
Author: User
/** * Retrieve an associated array, the first field value is the code, the second field is the value * @param int $field Two fields to look for * @param array $where query criteria * @return Array/Pub
     Lic function Fetchpairs ($field, $where = Array ()) {$where [' terminalid '] = Get_terminalid ();
     $results = $this->findall ($where, $field);
     $data = Array (); if (Is_array ($results) && count ($results) > 0) {foreach ($results as $value) {$data [$val
         ue[$field [0]]] = $value [$field [1]];
     return $data;
     else {return false;
/** * Gets a key value in a two-dimensional array with a unique key value @param array $input two-dimensional array * @param string $columnKey The key of the array @param string $indexKey The index of the array +----------------------------------------------------------* @return Array returns the value +--------------------------------- -------------------------/function Array_column_unique (array $input, $columnKey, $indexKey = null) {return Array_u
Nique (Array_column ($input, $columnKey, $indexKey)); Call method protected function _format ($list) {//access to professional information $specIds = Array_column_unique ($list, "specid"); Count ($specIds) && $specData = D (' huaqin/specialty ')->fetchpairs (array (' ID ', ' zymc '), array ("ID" =>
    
        Array ("in", $specIds));   
        Educational system Data $xuezhiIds = Array_column_unique ($list, "XZ"); Count ($xuezhiIds) && $xuezhiData = D (' Huaqin/xuezi ')->fetchpairs (array (' ID ', ' XZMC '), array ("ID" =>
    
        Array ("in", $xuezhiIds));
            foreach ($list as & $value) {$value [' zymc '] = $specData [$value [' specid ']];
        $value [' xzmc '] = $xuezhiData [$value [' XZ ']];
    return $list;
  }


   /**
         * Retrieve an associated array, the first field value is the code, the second field is the value
         * @param array   $field two field array to look for (' Field 1 ', ' Field 2 ')
         * @param array $ where query condition
         * @return Array
         *
        /Public Function fetchpairs ($field, $where = Array ())
        {
            $where [' Terminalid '] = Get_terminalid ();
            $results = $this->findall ($where, $field);
            $data = Array ();
            if (Is_array ($results) && count ($results) > 0) {
                foreach ($results as $value) {
                    $data [$value [$field [0]]] = $value [$field [1]];
                }
                return $data;
            } else {return
                false;
            }
        }


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.