original_string: public function getList(array $options = array())
      {
          $result = null;
          $this->hook->attach('product.class.list.before', $options, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $sql = 'SELECT pc.*';
  
          if (!empty($options['count'])) {
              $sql = 'SELECT COUNT(pc.product_class_id)';
          }
  
          $sql .= ' FROM product_class pc WHERE pc.product_class_id IS NOT NULL';
  
          $conditions = array();
  
          if (isset($options['title'])) {
              $sql .= ' AND pc.title LIKE ?';
              $conditions[] = "%{$options['title']}%";
          }
  
          if (isset($options['status'])) {
              $sql .= ' AND pc.status=?';
              $conditions[] = (int) $options['status'];
          }
  
          $allowed_order = array('asc', 'desc');
          $allowed_sort = array('title', 'status', 'product_class_id');
  
          $sql .= ' GROUP BY pc.product_class_id';
  
          if (isset($options['sort'])
              && in_array($options['sort'], $allowed_sort)
              && isset($options['order'])
              && in_array($options['order'], $allowed_order)) {
              $sql .= " ORDER BY pc.{$options['sort']} {$options['order']}";
          } else {
              $sql .= ' ORDER BY pc.title ASC';
          }
  
          if (!empty($options['limit'])) {
              $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
          }
  
          if (empty($options['count'])) {
              $result = $this->db->fetchAll($sql, $conditions, array('index' => 'product_class_id'));
          } else {
              $result = (int) $this->db->fetchColumn($sql, $conditions);
          }
  
          $this->hook->attach('product.class.list.after', $options, $result, $this);
          return $result;
      }
code: public function getList(array $options = array())
      {
          $result = null;
          $this->hook->attach('product.class.list.before', $options, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $sql = 'SELECT pc.*';
  
          if (!empty($options['count'])) {
              $sql = 'SELECT COUNT(pc.product_class_id)';
          }
  
          $sql .= ' FROM product_class pc WHERE pc.product_class_id IS NOT NULL';
  
          $conditions = array();
  
          if (isset($options['title'])) {
              $sql .= ' AND pc.title LIKE ?';
              $conditions[] = "%{$options['title']}%";
          }
  
          if (isset($options['status'])) {
              $sql .= ' AND pc.status=?';
              $conditions[] = (int) $options['status'];
          }
  
          $allowed_order = array('asc', 'desc');
          $allowed_sort = array('title', 'status', 'product_class_id');
  
          $sql .= ' GROUP BY pc.product_class_id';
  
          if (isset($options['sort'])
              && in_array($options['sort'], $allowed_sort)
              && isset($options['order'])
              && in_array($options['order'], $allowed_order)) {
              $sql .= " ORDER BY pc.{$options['sort']} {$options['order']}";
          } else {
              $sql .= ' ORDER BY pc.title ASC';
          }
  
          if (!empty($options['limit'])) {
              $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
          }
  
          if (empty($options['count'])) {
              $result = $this->db->fetchAll($sql, $conditions, array('index' => 'product_class_id'));
          } else {
              $result = (int) $this->db->fetchColumn($sql, $conditions);
          }
  
          $this->hook->attach('product.class.list.after', $options, $result, $this);
          return $result;
      }
code_tokens: public function getList ( array $ options = array ( ) ) { $ result = null ; $ this -> hook -> attach ( 'product.class.list.before' , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ sql = 'SELECT pc.*' ; if ( ! empty ( $ options [ 'count' ] ) ) { $ sql = 'SELECT COUNT(pc.product_class_id)' ; } $ sql .= ' FROM product_class pc WHERE pc.product_class_id IS NOT NULL' ; $ conditions = array ( ) ; if ( isset ( $ options [ 'title' ] ) ) { $ sql .= ' AND pc.title LIKE ?' ; $ conditions [ ] = "%{$options['title']}%" ; } if ( isset ( $ options [ 'status' ] ) ) { $ sql .= ' AND pc.status=?' ; $ conditions [ ] = ( int ) $ options [ 'status' ] ; } $ allowed_order = array ( 'asc' , 'desc' ) ; $ allowed_sort = array ( 'title' , 'status' , 'product_class_id' ) ; $ sql .= ' GROUP BY pc.product_class_id' ; if ( isset ( $ options [ 'sort' ] ) && in_array ( $ options [ 'sort' ] , $ allowed_sort ) && isset ( $ options [ 'order' ] ) && in_array ( $ options [ 'order' ] , $ allowed_order ) ) { $ sql .= " ORDER BY pc.{$options['sort']} {$options['order']}" ; } else { $ sql .= ' ORDER BY pc.title ASC' ; } if ( ! empty ( $ options [ 'limit' ] ) ) { $ sql .= ' LIMIT ' . implode ( ',' , array_map ( 'intval' , $ options [ 'limit' ] ) ) ; } if ( empty ( $ options [ 'count' ] ) ) { $ result = $ this -> db -> fetchAll ( $ sql , $ conditions , array ( 'index' => 'product_class_id' ) ) ; } else { $ result = ( int ) $ this -> db -> fetchColumn ( $ sql , $ conditions ) ; } $ this -> hook -> attach ( 'product.class.list.after' , $ options , $ result , $ this ) ; return $ result ; }
docstring: Returns an array of product classes or counts them
  @param array $options
  @return array|integer
docstring_tokens: Returns an array of product classes or counts them