function sort($collection, $comparator = 'Dash\\Functions\\compare') { $array = mapValues($collection); uasort($array, $comparator); // uasort() is an in-place sort return $array; }
function toArray($collection) { return mapValues($collection); }
<?php include_once '../function_header.php'; $orderby = ""; $table = $_GET['table']; $where = isset($_GET['where']) ? $_GET['where'] : 1; $condition = isset($_GET['condition']) ? $_GET['condition'] : 1; $type = $_GET['type']; $order = $_GET['order']; if (isset($_GET['order'])) { $orderby = "ORDER BY {$order} {$type}"; } $id = $_GET['id']; $values = $_GET['values']; $objectId = $_GET['objectId']; $objectName = $_GET['objectName']; $objectQuery = "\n\tSELECT\n\t\t*\n\tFROM\n\t\t{$table}\n\tWHERE\n\t\t{$where} = {$condition}\n\t{$orderby}\n\t"; //echo $objectQuery; $objects = mysql_query($objectQuery, $conexion); $jsondata['objectId'] = $objectId; $jsondata['options'][0] = " --Select {$objectName}--"; while ($row = mysql_fetch_assoc($objects)) { $jsondata['options'][$row[$id]] = mapValues($row, $values, '_'); } echo json_encode($jsondata); mysql_close();
function findLast($collection, $predicate) { $values = mapValues($collection); $reversed = reverse($values); return find($reversed, $predicate); }
if (!$flows[$flow[0]]) { if ($val > 1.00825 && $flow[0] != 'XS' && $flow[0] != 'XN' && $flow[1] != 'XS' && $flow[1] != 'XN') { $flows[$flow[0]] = array("flows" => array()); } } //$flows[$flow[0]]["flows"][$flow[1]]=array("flow"=>$flow[2]); if ($val > 1.00825 && $flow[0] != 'XS' && $flow[0] != 'XN' && $flow[1] != 'XS' && $flow[1] != 'XN') { $flows[$flow[0]]["flows"][$flow[1]] = round($val); } //array("flow"=>round($val)); } } else { foreach ($c as $flow) { //$val=ceil($flow[2]/$max['MX']*100); $max_value = 120; $val = mapValues($flow[2], 0, $max['MX'], 0, $max_value); if (!$flows[$flow[0]]) { if ($val > 0 && $flow[0] != 'XS' && $flow[0] != 'XN' && $flow[1] != 'XS' && $flow[1] != 'XN') { $flows[$flow[0]] = array("flows" => array()); } } //$flows[$flow[0]]["flows"][$flow[1]]=array("flow"=>$flow[2]); if ($val > 0 && $flow[0] != 'XS' && $flow[0] != 'XN' && $flow[1] != 'XS' && $flow[1] != 'XN') { $flows[$flow[0]]["flows"][$flow[1]] = $val; } //round($val/2.001);//array("flow"=>round($val)); } } } //var_export($flows); echo json_encode($flows);
function objectArray($handler, $table, $orderBy, $id, $values) { $objectQuery = "SELECT * FROM {$table} " . ($orderBy == "" ? "" : "ORDER BY {$orderBy}"); $objects = mysql_query($objectQuery, $handler); $objectArray = array(); while ($object = mysql_fetch_assoc($objects)) { $objectArray[$object[$id]] = mapValues($object, $values); } return $objectArray; }
function reverse($collection) { return array_reverse(mapValues($collection), true); }
function takeRight($collection, $count = 1, $fromEnd = 0) { $values = mapValues($collection); $reversed = reverse($values); return take($reversed, $count, $fromEnd); }