You are here

function properties_sql_properties_attribute_load_paging in Dynamic properties 7

Load a paged amount of attributes.

Parameters

$per_page: Number of attributes per page.

File

properties_sql/properties_sql.module, line 68
This module implements the attribute and category API with a SQL backend.

Code

function properties_sql_properties_attribute_load_paging($per_page, array $options = array()) {
  $query = db_select('properties_attribute', 'pa')
    ->extend('PagerDefault')
    ->fields('pa')
    ->limit($per_page);
  if (isset($options['header'])) {
    $query = $query
      ->extend('TableSort')
      ->orderByHeader($options['header']);
  }
  if (!empty($options['search'])) {
    $query
      ->condition(db_or()
      ->condition('name', $options['search'] . '%', 'LIKE')
      ->condition('label', $options['search'] . '%', 'LIKE'));
  }
  return $query
    ->execute()
    ->fetchAllAssoc('name');
}