当前位置: 首页>>代码示例>>PHP>>正文


PHP Part::get_category方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:101,代码来源:class.Part.php

示例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 {
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:31,代码来源:show_part_info.php


注:本文中的Part::get_category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。