Example #1
0
function object2Array($stdclassobject)
{
    $_array = is_object($stdclassobject) ? get_object_vars($stdclassobject) : $stdclassobject;
    foreach ($_array as $key => $value) {
        $value = is_array($value) || is_object($value) ? object2Array($value) : $value;
        $array[$key] = $value;
    }
    return $array;
}
Example #2
0
 public function get($storeId)
 {
     $obj = $this->client->hasConsumer($this->project, '1', $this->group, $storeId);
     $arr = object2Array($obj);
     if ($arr['status'] != 0) {
         $this->client->createConsumer($this->project, '1', $this->group, $storeId);
     }
     return $this->client->batchConsume($this->group, $storeId, 5);
 }
function paseXml($xml)
{
    $content = file_get_contents($xml);
    if (!empty($content)) {
        $xml = simplexml_load_file($xml);
        $result = object2Array($xml);
    } else {
        $result = '';
    }
    return $result;
}
Example #4
0
						<?php 
//helper function
function object2Array($d)
{
    if (is_object($d)) {
        $d = get_object_vars($d);
    }
    if (is_array($d)) {
        return array_map(__FUNCTION__, $d);
    } else {
        return $d;
    }
}
//create navigation
$parent = NULL;
$menuarray = object2Array($ot_array);
$ot_mainmenu = array();
foreach ($menuarray as $key => $value) {
    //create first level
    if ($value['item_type'] == 'heading') {
        $parent = $value['id'];
        $ot_mainmenu[$parent] = $value;
    }
    //create second level
    if ($value['item_type'] == 'subheading') {
        $subitem = $value;
        $ot_mainmenu[$parent]['childs'][$key] = $subitem;
        //array_push($ot_mainmenu, $subitem);
    }
}
?>
Example #5
0
 /**
  * Adds table fields as class properties to current "record" class.
  *
  * Loads Table schema data and creates new class properties based
  * upon the fields in given table.
  *
  * Additionally, if a record ID is given, that record is pulled and
  * field values are also populated into class properties.
  *
  * @name build
  *
  * @category db_record
  * @uses [db_type]::getDataDefinition() Builds  a data definition from existing table.
  * @requires $db
  *
  * @access protected
  * @final
  * @PHPUnit Not Defined
  *
  * @global object $db
  * @param mixed $params array or Object for table selection
  *
  * @return none
  * @throws none
  *
  */
 public function build($params = array())
 {
     global $db;
     // safeguard against bad data...we can only take objects and arrays here
     if (!is_array($params) && !is_object($params)) {
         $params = array();
     }
     // get the table definition and make sure all the params being passed in belong in this table
     $table = $db->getDataDefinition($this->tablename);
     //check for location_data
     if (is_array($params) && (!empty($params['module']) && !empty($params['src']))) {
         $params['location_data'] = serialize(makeLocation($params['module'], $params['src']));
     } elseif (is_object($params) && (!empty($params->module) && !empty($params->src))) {
         $params->location_data = serialize(makeLocation($params->module, $params->src));
     }
     // Build Class properties based off table fields
     foreach ($table as $col => $colDef) {
         // check if the DB column has a corresponding value in the params array
         // if not, we check to see if the column is boolean...if so we set it to false
         // if not, then we check to see if we had a previous value in this particular
         // record.  if so we reset it to itself so we don't lose the existing value.
         // this is good for when the developer is trying to update just a field or two
         // in an existing record.
         if (array_key_exists($col, $params)) {
             $value = is_array($params) ? $params[$col] : $params->{$col};
             if ($colDef[0] == DB_DEF_INTEGER || $colDef[0] == DB_DEF_ID) {
                 $this->{$col} = preg_replace("/[^0-9-]/", "", $value);
             } elseif ($colDef[0] == DB_DEF_DECIMAL) {
                 $this->{$col} = preg_replace("/[^0-9.-]/", "", $value);
             } else {
                 $this->{$col} = $value;
             }
         } elseif ($colDef[0] == DB_DEF_BOOLEAN) {
             $this->{$col} = empty($this->{$col}) ? 0 : $this->{$col};
         } elseif ($colDef[0] == DB_DEF_TIMESTAMP) {
             $datename = $col . 'date';
             if (is_array($params) && isset($params[$datename])) {
                 $this->{$col} = yuidatetimecontrol::parseData($col, $params);
             } elseif (is_object($params) && isset($params->{$datename})) {
                 $this->{$col} = yuidatetimecontrol::parseData($col, object2Array($params));
             } else {
                 $this->{$col} = !empty($this->{$col}) ? $this->{$col} : 0;
             }
         } else {
             $this->{$col} = !empty($this->{$col}) ? $this->{$col} : null;
         }
         //if (isset($this->col)) {
         $this->{$col} = stripslashes($this->{$col});
         //}
     }
 }
function formatKml($res, $kmls)
{
    $rdata = [];
    $key = '';
    if (!empty($res)) {
        foreach ($res as $d) {
            $storeId = $d['storeId'];
            $rtNum = $d['rtNum'];
            $key = $storeId . $rtNum;
            $itno = !empty($d['itno']) ? $d['itno'] : '';
            $qty = !empty($d['qty']) ? $d['qty'] : '';
            $rdata[$key] = $d['kmlStatus'] . ',' . $itno . ',' . $qty;
        }
    }
    $data = $arr = [];
    $kmlarr = object2Array($kmls);
    ksort($kmlarr);
    foreach ($kmlarr as $k => $kml) {
        $arr = explode(',', $rdata[$kml['DIANHAO'] . $kml['RTHUOHAO']]);
        $data[$k]['storeId'] = $kml['DIANHAO'];
        $data[$k]['rtNum'] = $kml['RTHUOHAO'];
        $data[$k]['distribution'] = $kml['FENPEI'];
        $data[$k]['kmlStatus'] = $arr[0];
        $data[$k]['itno'] = $arr[1];
        $data[$k]['qty'] = $arr[2];
        $data[$k]['docTime'] = $kml['DOC_TIME'];
        $data[$k]['kmlPath'] = $kml['KML_FILE'];
        $data[$k]['createTime'] = $kml['CREATE_TIME'];
        $data[$k]['updateTime'] = date('Y-m-d H:i:s');
        $arr = [];
    }
    return $data;
}