本文整理汇总了PHP中Part::get_category方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::get_category方法的具体用法?PHP Part::get_category怎么用?PHP Part::get_category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::get_category方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_parts
//.........这里部分代码省略.........
* @param boolean $manufacturer_name if ture, the search will include this attribute
*
* @retval array all found parts as a one-dimensional array of Part objects,
* sorted by their names (if "$group_by == ''")
* @retval array @li all parts as a two-dimensional array, grouped by $group_by,
* sorted by name (if "$group_by != ''")
* @li example: array('category1' => array(part1, part2, ...),
* 'category2' => array(part123, part124, ...), ...)
* @li for the group names (in the example 'category1', 'category2', ...)
* are the full paths used
*
* @throws Exception if there was an error
*/
public static function search_parts(&$database, &$current_user, &$log, $keyword, $group_by = '', $part_name = true, $part_description = true, $part_comment = false, $footprint_name = false, $category_name = false, $storelocation_name = false, $supplier_name = false, $supplierpartnr = false, $manufacturer_name = false)
{
global $config;
$keyword = trim($keyword);
if (strlen($keyword) == 0) {
return array();
}
$keyword = str_replace('*', '%', $keyword);
$keyword = '%' . $keyword . '%';
$groups = array();
$parts = array();
$values = array();
$query = 'SELECT parts.id FROM parts' . ' LEFT JOIN footprints ON parts.id_footprint=footprints.id' . ' LEFT JOIN storelocations ON parts.id_storelocation=storelocations.id' . ' LEFT JOIN manufacturers ON parts.id_manufacturer=manufacturers.id' . ' LEFT JOIN categories ON parts.id_category=categories.id' . ' LEFT JOIN orderdetails ON parts.id=orderdetails.part_id' . ' LEFT JOIN suppliers ON orderdetails.id_supplier=suppliers.id' . ' WHERE FALSE';
if ($part_name) {
$query .= ' OR (parts.name LIKE ?)';
$values[] = $keyword;
}
if ($part_description) {
$query .= ' OR (parts.description LIKE ?)';
$values[] = $keyword;
}
if ($part_comment) {
$query .= ' OR (parts.comment LIKE ?)';
$values[] = $keyword;
}
if ($footprint_name) {
$query .= ' OR (footprints.name LIKE ?)';
$values[] = $keyword;
}
if ($category_name) {
$query .= ' OR (categories.name LIKE ?)';
$values[] = $keyword;
}
if ($storelocation_name) {
$query .= ' OR (storelocations.name LIKE ?)';
$values[] = $keyword;
}
if ($supplier_name) {
$query .= ' OR (suppliers.name LIKE ?)';
$values[] = $keyword;
}
if ($supplierpartnr) {
$query .= ' OR (orderdetails.supplierpartnr LIKE ?)';
$values[] = $keyword;
}
if ($manufacturer_name) {
$query .= ' OR (manufacturers.name LIKE ?)';
$values[] = $keyword;
}
if (!isset($config['db']['limit']['search_parts'])) {
$config['db']['limit']['search_parts'] = 200;
}
switch ($group_by) {
case '':
$query .= ' GROUP BY parts.id ORDER BY parts.name ASC';
if (isset($config['db']['limit']['search_parts']) && $config['db']['limit']['search_parts'] > 0) {
$query .= ' LIMIT ' . $config['db']['limit']['search_parts'];
}
break;
case 'categories':
$query .= ' GROUP BY parts.id ORDER BY categories.id, parts.name ASC';
if (isset($config['db']['limit']['search_parts']) && $config['db']['limit']['search_parts'] > 0) {
$query .= ' LIMIT ' . $config['db']['limit']['search_parts'];
}
break;
default:
throw new Exception('$group_by="' . $group_by . '" is not supported!');
}
$query_data = $database->query($query, $values);
foreach ($query_data as $row) {
$part = new Part($database, $current_user, $log, $row['id']);
switch ($group_by) {
case '':
$parts[] = $part;
break;
case 'categories':
$groups[$part->get_category()->get_full_path()][] = $part;
break;
}
}
if ($group_by != '') {
ksort($groups);
return $groups;
} else {
return $parts;
}
}
示例2: HTML
/********************************************************************************
*
* Initialize Objects
*
*********************************************************************************/
$html = new HTML($config['html']['theme'], $config['html']['custom_css'], 'Detailinfo');
try {
$database = new Database();
$log = new Log($database);
$current_user = new User($database, $current_user, $log, 1);
// admin
$part = new Part($database, $current_user, $log, $part_id);
$footprint = $part->get_footprint();
$storelocation = $part->get_storelocation();
$manufacturer = $part->get_manufacturer();
$category = $part->get_category();
$all_orderdetails = $part->get_orderdetails();
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
$fatal_error = true;
}
/********************************************************************************
*
* Execute actions
*
*********************************************************************************/
if (!$fatal_error) {
switch ($action) {
case 'dec':
// remove some parts
try {