Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

udm_cat_path(3) [php man page]

UDM_CAT_PATH(3) 							 1							   UDM_CAT_PATH(3)

udm_cat_path - Get the path to the current category

SYNOPSIS
array udm_cat_path (resource $agent, string $category) DESCRIPTION
Returns an array describing the path in the categories tree from the tree root to the current one, specified by $category. PARAMETERS
o $agent - A link to Agent, received after call to udm_alloc_agent(3). o $category - RETURN VALUES
The returned array consists of pairs. Elements with even index numbers contain the category paths, odd elements contain the corresponding category names. For example, the call $array=udm_cat_path($agent, '02031D'); may return the following array: $array[0] will contain '' $array[1] will contain 'Root' $array[2] will contain '02' $array[3] will contain 'Sport' $array[4] will contain '0203' $array[5] will contain 'Auto' $array[4] will contain '02031D' $array[5] will contain 'Ferrari' EXAMPLES
Example #1 Specifying path to the current category in the following format: '> Root > Sport > Auto > Ferrari' <?php $cat_path_arr = udm_cat_path($udm_agent, $cat); $cat_path = ''; for ($i=0; $i<count($cat_path_arr); $i+=2) { $path = $cat_path_arr[$i]; $name = $cat_path_arr[$i+1]; $cat_path .= " > <a href="$_SERVER[PHP_SELF]?cat=$path">$name</a> "; } ?> SEE ALSO
udm_cat_list(3). PHP Documentation Group UDM_CAT_PATH(3)

Check Out this Related Man Page

MONGOCOLLECTION.GROUP(3)						 1						  MONGOCOLLECTION.GROUP(3)

MongoCollection::group - Performs an operation similar to SQL's GROUP BY command

SYNOPSIS
public array MongoCollection::group (mixed $keys, array $initial, MongoCode $reduce, [array $options = array()]) DESCRIPTION
PARAMETERS
o $keys - Fields to group by. If an array or non-code object is passed, it will be the key used to group results. 1.0.4+: If $keys is an instance of MongoCode, $keys will be treated as a function that returns the key to group by (see the "Passing a $keys function" example below). o $initial - Initial value of the aggregation counter object. o $reduce - A function that takes two arguments (the current document and the aggregation to this point) and does the aggregation. o $options - Optional parameters to the group command. Valid options include: o "condition" Criteria for including a document in the aggregation. o "finalize" Function called once per unique key that takes the final output of the reduce function. o "maxTimeMS"Specifies a cumulative time limit in milliseconds for processing the operation (does not include idle time). If the operation is not completed within the timeout period, a MongoExecutionTimeoutException will be thrown. RETURN VALUES
Returns an array containing the result. CHANGELOG
+--------+----------------------------------------------+ |Version | | | | | | | Description | | | | +--------+----------------------------------------------+ | 1.5.0 | | | | | | | Added "maxTimeMS" option. | | | | |1.2.11 | | | | | | | Emits E_DEPRECATED when $options is scalar. | | | | +--------+----------------------------------------------+ EXAMPLES
Example #1 MongoCollection.group(3) example This groups documents by category and creates a list of names within that category. <?php $collection->insert(array("category" => "fruit", "name" => "apple")); $collection->insert(array("category" => "fruit", "name" => "peach")); $collection->insert(array("category" => "fruit", "name" => "banana")); $collection->insert(array("category" => "veggie", "name" => "corn")); $collection->insert(array("category" => "veggie", "name" => "broccoli")); $keys = array("category" => 1); $initial = array("items" => array()); $reduce = "function (obj, prev) { prev.items.push(obj.name); }"; $g = $collection->group($keys, $initial, $reduce); echo json_encode($g['retval']); ?> The above example will output something similar to: [{"category":"fruit","items":["apple","peach","banana"]},{"category":"veggie","items":["corn","broccoli"]}] Example #2 MongoCollection.group(3) example This example doesn't use any key, so every document will be its own group. It also uses a condition: only documents that match this condition will be processed by the grouping function. <?php $collection->save(array("a" => 2)); $collection->save(array("b" => 5)); $collection->save(array("a" => 1)); // use all fields $keys = array(); // set intial values $initial = array("count" => 0); // JavaScript function to perform $reduce = "function (obj, prev) { prev.count++; }"; // only use documents where the "a" field is greater than 1 $condition = array('condition' => array("a" => array( '$gt' => 1))); $g = $collection->group($keys, $initial, $reduce, $condition); var_dump($g); ?> The above example will output something similar to: array(4) { ["retval"]=> array(1) { [0]=> array(1) { ["count"]=> float(1) } } ["count"]=> float(1) ["keys"]=> int(1) ["ok"]=> float(1) } Example #3 Passing a $keys function If you want to group by something other than a field name, you can pass a function as the first parameter of MongoCollec- tion.group(3) and it will be run against each document. The return value of the function will be used as its grouping value. This example demonstrates grouping by the num field modulo 4. <?php $c->group(new MongoCode('function(doc) { return {mod : doc.num % 4}; }'), array("count" => 0), new MongoCode('function(current, total) { total.count++; }')); ?> PHP Documentation Group MONGOCOLLECTION.GROUP(3)
Man Page