本文整理匯總了PHP中sDB::found方法的典型用法代碼示例。如果您正苦於以下問題:PHP sDB::found方法的具體用法?PHP sDB::found怎麽用?PHP sDB::found使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sDB
的用法示例。
在下文中一共展示了sDB::found方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: screen
public function screen()
{
if (!current_user_can('shopp_promotions')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$table = ShoppDatabaseObject::tablename(ShoppPromo::$table);
$defaults = array('page' => false, 'status' => false, 'type' => false, 'paged' => 1, 'per_page' => 20, 's' => '');
$args = array_merge($defaults, $_GET);
extract($args, EXTR_SKIP);
$url = add_query_arg(array_merge($_GET, array('page' => $this->page)), admin_url('admin.php'));
$f = array('action', 'selected', 's');
$url = remove_query_arg($f, $url);
$pagenum = absint($paged);
$start = $per_page * ($pagenum - 1);
$where = array();
if (!empty($s)) {
$where[] = "name LIKE '%{$s}%'";
}
if ($status) {
$datesql = ShoppPromo::activedates();
switch (strtolower($status)) {
case 'active':
$where[] = "status='enabled' AND {$datesql}";
break;
case 'inactive':
$where[] = "status='enabled' AND NOT {$datesql}";
break;
case 'enabled':
$where[] = "status='enabled'";
break;
case 'disabled':
$where[] = "status='disabled'";
break;
}
}
if ($type) {
switch (strtolower($type)) {
case 'catalog':
$where[] = "target='Catalog'";
break;
case 'cart':
$where[] = "target='Cart'";
break;
case 'cartitem':
$where[] = "target='Cart Item'";
break;
}
}
$select = sDB::select(array('table' => $table, 'columns' => 'SQL_CALC_FOUND_ROWS *', 'where' => $where, 'orderby' => 'created DESC', 'limit' => "{$start},{$per_page}"));
$Promotions = sDB::query($select, 'array');
$count = sDB::found();
$num_pages = ceil($count / $per_page);
$ListTable = ShoppUI::table_set_pagination($this->id, $count, $num_pages, $per_page);
$states = array('active' => __('Active', 'Shopp'), 'inactive' => __('Not Active', 'Shopp'), 'enabled' => __('Enabled', 'Shopp'), 'disabled' => __('Disabled', 'Shopp'));
$types = array('catalog' => __('Catalog Discounts', 'Shopp'), 'cart' => __('Cart Discounts', 'Shopp'), 'cartitem' => __('Cart Item Discounts', 'Shopp'));
$num_pages = ceil($count / $per_page);
$page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => $num_pages, 'current' => $pagenum));
include $this->ui('discounts.php');
}
示例2: prepare_items
public function prepare_items()
{
$defaults = array('paged' => 1, 'per_page' => 25, 'action' => false, 'selected' => array());
$args = array_merge($defaults, $_GET);
extract($args, EXTR_SKIP);
$start = $per_page * ($paged - 1);
$edit = false;
$ImageSetting = new ShoppImageSetting($edit);
$table = $ImageSetting->_table;
$columns = 'SQL_CALC_FOUND_ROWS *';
$where = array("type='{$ImageSetting->type}'", "context='{$ImageSetting->context}'");
$limit = "{$start},{$per_page}";
$options = compact('columns', 'useindex', 'table', 'joins', 'where', 'groupby', 'having', 'limit', 'orderby');
$query = sDB::select($options);
$this->items = sDB::query($query, 'array', array($ImageSetting, 'loader'));
$found = sDB::found();
$json = array();
$skip = array('created', 'modified', 'numeral', 'context', 'type', 'sortorder', 'parent');
foreach ($this->items as &$Item) {
if (method_exists($Item, 'json')) {
$json[$Item->id] = $Item->json($skip);
}
}
shopp_custom_script('imageset', 'var images = ' . json_encode($json) . ';');
$this->set_pagination_args(array('total_items' => $found, 'total_pages' => $found / $per_page, 'per_page' => $per_page));
}
示例3: screen
//.........這裏部分代碼省略.........
//
// }
$pagenum = absint($paged);
if (empty($pagenum)) {
$pagenum = 1;
}
if (!$per_page || $per_page < 0) {
$per_page = 20;
}
$index = $per_page * ($pagenum - 1);
if (!empty($start)) {
$startdate = $start;
list($month, $day, $year) = explode("/", $startdate);
$starts = mktime(0, 0, 0, $month, $day, $year);
}
if (!empty($end)) {
$enddate = $end;
list($month, $day, $year) = explode("/", $enddate);
$ends = mktime(23, 59, 59, $month, $day, $year);
}
$customer_table = ShoppDatabaseObject::tablename(Customer::$table);
$billing_table = ShoppDatabaseObject::tablename(BillingAddress::$table);
$purchase_table = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$users_table = $wpdb->users;
$where = array();
if (!empty($s)) {
$s = stripslashes($s);
if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER)) {
foreach ($props as $search) {
$keyword = !empty($search[2]) ? $search[2] : $search[3];
switch (strtolower($search[1])) {
case "company":
$where[] = "c.company LIKE '%{$keyword}%'";
break;
case "login":
$where[] = "u.user_login LIKE '%{$keyword}%'";
break;
case "address":
$where[] = "(b.address LIKE '%{$keyword}%' OR b.xaddress='%{$keyword}%')";
break;
case "city":
$where[] = "b.city LIKE '%{$keyword}%'";
break;
case "province":
case "state":
$where[] = "b.state='{$keyword}'";
break;
case "zip":
case "zipcode":
case "postcode":
$where[] = "b.postcode='{$keyword}'";
break;
case "country":
$where[] = "b.country='{$keyword}'";
break;
}
}
} elseif (strpos($s, '@') !== false) {
$where[] = "c.email='{$s}'";
} elseif (is_numeric($s)) {
$where[] = "c.id='{$s}'";
} else {
$where[] = "(CONCAT(c.firstname,' ',c.lastname) LIKE '%{$s}%' OR c.company LIKE '%{$s}%')";
}
}
if (!empty($starts) && !empty($ends)) {
$where[] = ' (UNIX_TIMESTAMP(c.created) >= ' . $starts . ' AND UNIX_TIMESTAMP(c.created) <= ' . $ends . ')';
}
$select = array('columns' => 'SQL_CALC_FOUND_ROWS c.*,city,state,country,user_login', 'table' => "{$customer_table} as c", 'joins' => array($billing_table => "LEFT JOIN {$billing_table} AS b ON b.customer=c.id AND b.type='billing'", $users_table => "LEFT JOIN {$users_table} AS u ON u.ID=c.wpuser AND (c.wpuser IS NULL OR c.wpuser != 0)"), 'where' => $where, 'groupby' => "c.id", 'orderby' => "c.created DESC", 'limit' => "{$index},{$per_page}");
$query = sDB::select($select);
$Customers = sDB::query($query, 'array', 'index', 'id');
$total = sDB::found();
// Add order data to customer records in this view
$orders = sDB::query("SELECT customer,SUM(total) AS total,count(id) AS orders FROM {$purchase_table} WHERE customer IN (" . join(',', array_keys($Customers)) . ") GROUP BY customer", 'array', 'index', 'customer');
foreach ($Customers as &$record) {
$record->total = 0;
$record->orders = 0;
if (!isset($orders[$record->id])) {
continue;
}
$record->total = $orders[$record->id]->total;
$record->orders = $orders[$record->id]->orders;
}
$num_pages = ceil($total / $per_page);
$ListTable = ShoppUI::table_set_pagination(ShoppAdmin::screen(), $total, $num_pages, $per_page);
$ranges = array('all' => __('Show New Customers', 'Shopp'), 'today' => __('Today', 'Shopp'), 'week' => __('This Week', 'Shopp'), 'month' => __('This Month', 'Shopp'), 'quarter' => __('This Quarter', 'Shopp'), 'year' => __('This Year', 'Shopp'), 'yesterday' => __('Yesterday', 'Shopp'), 'lastweek' => __('Last Week', 'Shopp'), 'last30' => __('Last 30 Days', 'Shopp'), 'last90' => __('Last 3 Months', 'Shopp'), 'lastmonth' => __('Last Month', 'Shopp'), 'lastquarter' => __('Last Quarter', 'Shopp'), 'lastyear' => __('Last Year', 'Shopp'), 'lastexport' => __('Last Export', 'Shopp'), 'custom' => __('Custom Dates', 'Shopp'));
$exports = array('tab' => __('Tab-separated.txt', 'Shopp'), 'csv' => __('Comma-separated.csv', 'Shopp'), 'xls' => __('Microsoft® Excel.xls', 'Shopp'));
$formatPref = shopp_setting('customerexport_format');
if (!$formatPref) {
$formatPref = 'tab';
}
$columns = array_merge(Customer::exportcolumns(), BillingAddress::exportcolumns(), ShippingAddress::exportcolumns());
$selected = shopp_setting('customerexport_columns');
if (empty($selected)) {
$selected = array_keys($columns);
}
$authentication = shopp_setting('account_system');
$action = add_query_arg(array('page' => ShoppAdmin::pagename('customers')), admin_url('admin.php'));
include $this->ui('customers.php');
}
示例4: images
public function images()
{
if (!current_user_can('shopp_settings')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$defaults = array('paged' => 1, 'per_page' => 25, 'action' => false, 'selected' => array());
$args = array_merge($defaults, $_REQUEST);
extract($args, EXTR_SKIP);
$edit = false;
if (isset($_GET['id'])) {
$edit = (int) $_GET['id'];
if ('new' == $_GET['id']) {
$edit = 'new';
}
}
if (isset($_GET['delete']) || 'delete' == $action) {
check_admin_referer('shopp-settings-images');
if (!empty($_GET['delete'])) {
$selected[] = (int) $_GET['delete'];
}
$selected = array_filter($selected);
foreach ($selected as $delete) {
$Record = new ImageSetting((int) $delete);
$Record->delete();
}
}
if (!empty($_POST['save'])) {
check_admin_referer('shopp-settings-images');
$ImageSetting = new ImageSetting($edit);
$_POST['name'] = sanitize_title_with_dashes($_POST['name']);
$_POST['sharpen'] = floatval(str_replace('%', '', $_POST['sharpen']));
$ImageSetting->updates($_POST);
if (!empty($ImageSetting->name)) {
$ImageSetting->save();
}
}
$start = $per_page * ($paged - 1);
$ImageSetting = new ImageSetting($edit);
$table = $ImageSetting->_table;
$columns = 'SQL_CALC_FOUND_ROWS *';
$where = array("type='{$ImageSetting->type}'", "context='{$ImageSetting->context}'");
$limit = "{$start},{$per_page}";
$options = compact('columns', 'useindex', 'table', 'joins', 'where', 'groupby', 'having', 'limit', 'orderby');
$query = sDB::select($options);
$settings = sDB::query($query, 'array', array($ImageSetting, 'loader'));
$total = sDB::found();
$num_pages = ceil($total / $per_page);
$ListTable = ShoppUI::table_set_pagination($this->screen, $total, $num_pages, $per_page);
$fit_menu = $ImageSetting->fit_menu();
$quality_menu = $ImageSetting->quality_menu();
$actions_menu = array('delete' => __('Delete', 'Shopp'));
$json_settings = array();
$skip = array('created', 'modified', 'numeral', 'context', 'type', 'sortorder', 'parent');
foreach ($settings as &$Setting) {
if (method_exists($Setting, 'json')) {
$json_settings[$Setting->id] = $Setting->json($skip);
}
}
include $this->ui('images.php');
}
示例5: __construct
private function __construct()
{
$ImageSetting = new ShoppImageSetting();
$table = $ImageSetting->_table;
$where = array("type='{$ImageSetting->type}'", "context='{$ImageSetting->context}'");
$options = compact('table', 'where');
$query = sDB::select($options);
$this->populate(sDB::query($query, 'array', array($ImageSetting, 'loader'), false, 'name'));
$this->found = sDB::found();
}
示例6: load
//.........這裏部分代碼省略.........
$limit = "{$start},{$this->pagination}";
} else {
$limit = $hardlimit;
}
$limited = false;
// Flag that the result set does not have forced limits
} else {
$limited = true;
}
// The result set has forced limits
// Core query components
// Load core product data and product summary columns
$cols = array('p.ID', 'p.post_title', 'p.post_name', 'p.post_excerpt', 'p.post_status', 'p.post_date', 'p.post_modified', 's.modified AS summed', 's.sold', 's.grossed', 's.maxprice', 's.minprice', 's.ranges', 's.taxed', 's.stock', 's.lowstock', 's.inventory', 's.featured', 's.variants', 's.addons', 's.sale');
if ($ids) {
$cols = array('p.ID');
}
$columns = "SQL_CALC_FOUND_ROWS " . join(',', $cols) . ($columns !== false ? ',' . $columns : '');
$table = "{$Processing->_table} AS p";
$where[] = "p.post_type='" . ShoppProduct::posttype() . "'";
$joins[$summary_table] = "LEFT OUTER JOIN {$summary_table} AS s ON s.product=p.ID";
$options = compact('columns', 'useindex', 'table', 'joins', 'where', 'groupby', 'having', 'limit', 'orderby');
// Alphabetic pagination
if ('alpha' === $pagination || preg_match('/(0\\-9|[A-Z])/', $page)) {
// Setup Roman alphabet navigation
$alphanav = array_merge(array('0-9'), range('A', 'Z'));
$this->alpha = array_combine($alphanav, array_fill(0, count($alphanav), 0));
// Setup alphabetized index query
$a = $options;
$a['columns'] = "count(DISTINCT p.ID) AS total,IF(LEFT(p.post_title,1) REGEXP '[0-9]',LEFT(p.post_title,1),LEFT(SOUNDEX(p.post_title),1)) AS letter";
$a['groupby'] = "letter";
$alphaquery = sDB::select($a);
$cachehash = 'collection_alphanav_' . md5($alphaquery);
$cached = Shopp::cache_get($cachehash, 'shopp_collection_alphanav');
if ($cached) {
// Load from object cache, if available
$this->alpha = $cached;
$cached = false;
} else {
// Run query and cache results
$expire = apply_filters('shopp_collection_cache_expire', 43200);
$alpha = sDB::query($alphaquery, 'array', array($this, 'alphatable'));
Shopp::cache_set($cachehash, $alpha, 'shopp_collection_alphanav', $expire);
}
$this->paged = true;
if ($this->page == 1) {
$this->page = '0-9';
}
$alphafilter = $this->page == "0-9" ? "(LEFT(p.post_title,1) REGEXP '[0-9]') = 1" : "IF(LEFT(p.post_title,1) REGEXP '[0-9]',LEFT(p.post_title,1),LEFT(SOUNDEX(p.post_title),1))='{$this->page}'";
$options['where'][] = $alphafilter;
}
$query = sDB::select(apply_filters('shopp_collection_query', $options));
if ($debug) {
echo $query . BR . BR;
}
// Load from cached results if available, or run the query and cache the results
$cachehash = 'collection_' . md5($query);
$cached = Shopp::cache_get($cachehash, 'shopp_collection');
if ($cached) {
$this->products = $cached->products;
$this->total = $cached->total;
} else {
$expire = apply_filters('shopp_collection_cache_expire', 43200);
$cache = new stdClass();
if ($ids) {
$cache->products = $this->products = sDB::query($query, 'array', 'col', 'ID');
} else {
$cache->products = $this->products = sDB::query($query, 'array', array($Processing, 'loader'));
}
$cache->total = $this->total = sDB::found();
// If running a limited set, the reported total found should not exceed the limit (but can because of SQL_CALC_FOUND_ROWS)
// Don't use the limit if it is offset
if ($limited && false === strpos($limit, ',')) {
$cache->total = $this->total = min($limit, $this->total);
}
Shopp::cache_set($cachehash, $cache, 'shopp_collection', $expire);
}
if (false === $this->products) {
$this->products = array();
}
if ($ids) {
return $this->size() > 0;
}
// Finish up pagination construction
if ($this->pagination > 0 && $this->total > $this->pagination) {
$this->pages = ceil($this->total / $this->pagination);
if ($this->pages > 1) {
$this->paged = true;
}
}
// Load all requested product meta from other data sources
$Processing->load_data($load, $this->products);
// If products are missing summary data, resum them
if (isset($Processing->resum) && !empty($Processing->resum)) {
$Processing->load_data(array('prices'), $Processing->resum);
}
unset($Processing);
// Free memory
$this->loaded = true;
return $this->size() > 0;
}