本文整理汇总了PHP中ShoppDatabaseObject::tablename方法的典型用法代码示例。如果您正苦于以下问题:PHP ShoppDatabaseObject::tablename方法的具体用法?PHP ShoppDatabaseObject::tablename怎么用?PHP ShoppDatabaseObject::tablename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShoppDatabaseObject
的用法示例。
在下文中一共展示了ShoppDatabaseObject::tablename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$this->name = __('Database', 'Shopp');
$this->_table = ShoppDatabaseObject::tablename($this->_table);
$this->_metatable = ShoppDatabaseObject::tablename($this->_metatable);
}
示例2: 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');
}
示例3: query
function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) as period,\n\t\t\t\t\t\t\tSUM( ( SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase ) ) AS items,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) as subtotal,\n\t\t\t\t\t\t\tSUM(o.discount) as discounts\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
示例4: delete
public function delete()
{
if (empty($this->id)) {
return;
}
$price = $this->id;
parent::delete();
// clean up meta entries for deleted price
$metatable = ShoppDatabaseObject::tablename('meta');
$query = "DELETE FROM {$metatable} WHERE context='price' and parent={$price}";
sDB::query($query);
}
示例5: query
function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed', 'captured', 'CHARGED')";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) AS period,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) AS subtotal,\n\t\t\t\t\t\t\tSUM(o.tax) AS tax,\n\t\t\t\t\t\t\tSUM(o.freight) AS shipping,\n\t\t\t\t\t\t\tSUM(o.discount) AS discounts,\n\t\t\t\t\t\t\tSUM(o.total) AS total,\n\t\t\t\t\t\t\tAVG(o.total) AS orderavg,\n\t\t\t\t\t\t\tSUM( (SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase) ) AS items,\n\t\t\t\t\t\t\t(SELECT AVG(p.unitprice) FROM {$purchased_table} AS p WHERE o.id = p.purchase) AS itemavg\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
示例6: query
public function query()
{
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed', 'captured', 'CHARGED')";
$where = join(" AND ", $where);
$id = $this->timecolumn('o.created');
$orders_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(o.created) as period,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.subtotal) as subtotal,\n\t\t\t\t\t\t\tSUM(o.tax) as tax,\n\t\t\t\t\t\t\tSUM(p1.taxable) as taxable,\n\t\t\t\t\t\t\tAVG(p2.rate) as rate\n\t\t\t\t\tFROM {$orders_table} AS o\n\t\t\t\t\tLEFT JOIN (SELECT purchase, SUM(p.total) as taxable FROM {$purchased_table} AS p WHERE p.unittax > 0 GROUP BY purchase) p1 ON p1.purchase = o.id\n\t\t\t\t\tLEFT JOIN (SELECT purchase, AVG(p.unittax/p.unitprice) as rate FROM {$purchased_table} AS p WHERE p.unittax > 0 GROUP BY purchase) p2 ON p2.purchase = o.id\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id})";
return $query;
}
示例7: screen
public function screen()
{
$Shopp = Shopp::object();
if (!current_user_can('shopp_settings_checkout')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
$next_setting = shopp_setting('next_order_id');
if ($next->id > $next_setting) {
$next_setting = $next->id;
}
$term_recount = false;
if (!empty($_POST['save'])) {
check_admin_referer('shopp-setup-management');
$next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
if ($next_order_id >= $next->id) {
if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
$next_setting = $next_order_id;
}
}
$_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
// Recount terms when this setting changes
if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
$term_recount = true;
}
shopp_set_formsettings();
$this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
}
if ($term_recount) {
$taxonomy = ProductCategory::$taxon;
$terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
if (!empty($terms)) {
wp_update_term_count_now($terms, $taxonomy);
}
}
$states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
$statusLabels = shopp_setting('order_status');
$statesLabels = shopp_setting('order_states');
$reasonLabels = shopp_setting('cancel_reasons');
if (empty($reasonLabels)) {
$reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
}
$promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
$lowstock = shopp_setting('lowstock_level');
if (empty($lowstock)) {
$lowstock = 0;
}
include $this->ui('management.php');
}
示例8: shopp_orders
/**
* shopp_orders - get a list of purchases
*
* @api
* @since 1.2
*
* @param mixed $from (optional) mktime or SQL datetime, get purchases after this date/time.
* @param mixed $to (optional) mktime or SQL datetime, get purchased before this date/time.
* @param bool $items (optional default:true) load purchased items into the records, slightly slower operation
* @param array $customers (optional) list of int customer ids to limit the purchases to. All customers by default.
* @param int $limit (optional default:false) maximimum number of results to get, false for no limit
* @param string $order (optional default:DESC) DESC or ASC, for sorting in ascending or descending order.
* @param string $orderby (optional) The column used to sort records
* @param bool $paidonly (optional) Restrict to orders where payment has been completed
* @param bool $downloads (optional) Restrict to orders that have downloads
* @return array of Purchase objects
**/
function shopp_orders($from = false, $to = false, $items = true, array $customers = array(), $limit = false, $order = 'DESC', $orderby = 'id', $paidonly = false, $downloads = false)
{
$pt = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$pd = ShoppDatabaseObject::tablename(ShoppPurchased::$table);
$op = '<';
$where = array();
$dateregex = '/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/';
foreach (array($from, $to) as $datetime) {
if (!$datetime) {
continue;
}
if (1 == preg_match($dateregex, $datetime)) {
$where[] = "'{$datetime}' {$op} p.created";
} else {
if (is_int($datetime)) {
$where[] = "FROM_UNIXTIME({$datetime}) {$op} p.created";
}
}
$op = '>=';
}
if (!empty($customers)) {
$set = sDB::escape(implode(',', $customers));
$where[] = "0 < FIND_IN_SET(p.customer,'" . $set . "')";
}
if ($paidonly) {
$where[] = "p.txnstatus='captured'";
}
if ($items && $downloads) {
$where[] = " pd.download > 0";
}
$where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where);
if ((int) $limit > 0) {
$limit = " LIMIT {$limit}";
} else {
$limit = '';
}
if (!in_array(strtolower($orderby), array('id', 'created', 'modified'))) {
$orderby = 'id';
}
if ($items) {
$query = "SELECT pd.* FROM {$pd} AS pd INNER JOIN {$pt} AS p ON pd.purchase = p.id {$where} " . $limit;
$purchased = sDB::query($query, 'array', '_shopp_order_purchased');
$orders = sDB::query("SELECT * FROM {$pt} WHERE FIND_IN_SET(id,'" . join(',', array_keys($purchased)) . "') ORDER BY {$orderby} " . ('DESC' == $order ? 'DESC' : 'ASC'), 'array', '_shopp_order_purchase', $purchased);
} else {
$query = "SELECT * FROM {$pt} AS p {$where} ORDER BY {$orderby} " . ('DESC' == $order ? 'DESC' : 'ASC') . $limit;
$orders = sDB::query($query, 'array', '_shopp_order_purchase');
}
return $orders;
}
示例9: query
function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "o.txnstatus IN ('authed','captured')";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = "o.cardtype";
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchase_table} AS o\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
示例10: query
function query()
{
$this->options = array_merge(array('orderby' => '(pr.stock/pr.stocked)', 'order' => 'ASC'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "pr.inventory='on'";
$where = join(" AND ", $where);
if (!in_array(strtoupper($order), array('ASC', 'DESC'))) {
$order = 'DESC';
}
if (!in_array(strtolower($orderby), array('inventory'))) {
$orderby = '(pr.stock/pr.stocked)';
}
$ordercols = "{$orderby} {$order}";
$id = "pr.product,' ',pr.id";
$product_table = WPDatabaseObject::tablename(ShoppProduct::$table);
$summary_table = ShoppDatabaseObject::tablename(ProductSummary::$table);
$price_table = ShoppDatabaseObject::tablename('price');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCONCAT(p.post_title,' ',pr.label) AS product,\n\t\t\t\t\t\t\tpr.stock AS inventory,\n\t\t\t\t\t\t\tpr.stocked AS stocked,\n\t\t\t\t\t\t\t(pr.stock/pr.stocked)*100 AS level\n\t\t\t\t\tFROM {$price_table} AS pr\n\t\t\t\t\tJOIN {$product_table} AS p ON p.ID=pr.product\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
示例11: query
function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = 'c.id';
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$customer_table = ShoppDatabaseObject::tablename('customer');
$query = "SELECT {$id} AS id,\n\t\t\t\t\t\t\tCONCAT(c.firstname,' ',c.lastname) AS customer,\n\t\t\t\t\t\t\tSUM( (SELECT SUM(p.quantity) FROM {$purchased_table} AS p WHERE o.id = p.purchase) ) AS sold,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.id) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchase_table} as o\n\t\t\t\t\tINNER JOIN {$customer_table} AS c ON c.id=o.customer\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY {$id} ORDER BY {$ordercols}";
return $query;
}
示例12: query
public function query()
{
$this->options = array_merge(array('orderby' => 'orders', 'order' => 'desc'), $this->options);
extract($this->options, EXTR_SKIP);
$where = array();
$where[] = "o.created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
$where[] = "orders.txnstatus IN ('authed','captured')";
$where = join(" AND ", $where);
if (!in_array($order, array('asc', 'desc'))) {
$order = 'desc';
}
if (!in_array($orderby, array('orders', 'sold', 'grossed'))) {
$orderby = 'orders';
}
$ordercols = "{$orderby} {$order}";
$id = "o.product,' ',o.price";
$purchase_table = ShoppDatabaseObject::tablename('purchase');
$purchased_table = ShoppDatabaseObject::tablename('purchased');
$product_table = WPDatabaseObject::tablename(ShoppProduct::$table);
$price_table = ShoppDatabaseObject::tablename('price');
$query = "SELECT CONCAT({$id}) AS id,\n\t\t\t\t\t\t\tCONCAT(p.post_title,' ', IF(pr.context != 'product',pr.label,'')) AS product,\n\t\t\t\t\t\t\tpr.sku as sku,\n\t\t\t\t\t\t\tSUM(o.quantity) AS sold,\n\t\t\t\t\t\t\tCOUNT(DISTINCT o.purchase) AS orders,\n\t\t\t\t\t\t\tSUM(o.total) AS grossed\n\t\t\t\t\tFROM {$purchased_table} AS o INNER JOIN {$purchase_table} AS orders ON orders.id=o.purchase\n\t\t\t\t\tJOIN {$product_table} AS p ON p.ID=o.product\n\t\t\t\t\tJOIN {$price_table} AS pr ON pr.id=o.price\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tGROUP BY CONCAT({$id}) ORDER BY {$ordercols}";
return $query;
}
示例13: rebuild
/**
* Marks an individual product for summary recalculation
*
* Recalculating t
*
* @author Jonathan Davis
* @since 1.3
*
* @param integer $id The product ID to update
* @return boolean True if successful, false otherwise
**/
public static function rebuild($id)
{
$id = intval($id);
$table = ShoppDatabaseObject::tablename(ProductSummary::$table);
return sDB::query("UPDATE {$table} SET modified='" . self::RECALCULATE . "' WHERE product={$id} LIMIT 1");
}
示例14: shopp_empty_search_index
/**
* Destroy the entire product search index
*
* @api
* @since 1.3
*
* @return void
**/
function shopp_empty_search_index()
{
$index_table = ShoppDatabaseObject::tablename(ContentIndex::$table);
if (sDB::query("DELETE FROM {$index_table}")) {
return true;
}
return false;
}
示例15: status_counts
/**
* Retrieves the number of orders in each customized order status label
*
* @author Jonathan Davis
* @return void
**/
public function status_counts()
{
$table = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$labels = shopp_setting('order_status');
if (empty($labels)) {
return false;
}
$status = array();
$alltotal = sDB::query("SELECT count(*) AS total FROM {$table}", 'auto', 'col', 'total');
$r = sDB::query("SELECT status,COUNT(status) AS total FROM {$table} GROUP BY status ORDER BY status ASC", 'array', 'index', 'status');
$all = array('' => __('All Orders', 'Shopp'));
$labels = $all + $labels;
foreach ($labels as $id => $label) {
$_ = new StdClass();
$_->label = $label;
$_->id = $id;
$_->total = 0;
if (isset($r[$id])) {
$_->total = (int) $r[$id]->total;
}
if ('' === $id) {
$_->total = $alltotal;
}
$status[$id] = $_;
}
return $status;
}