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


PHP sDB::mkdatetime方法代码示例

本文整理汇总了PHP中sDB::mkdatetime方法的典型用法代码示例。如果您正苦于以下问题:PHP sDB::mkdatetime方法的具体用法?PHP sDB::mkdatetime怎么用?PHP sDB::mkdatetime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sDB的用法示例。


在下文中一共展示了sDB::mkdatetime方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:12,代码来源:discounts.php

示例2: 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;
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:13,代码来源:sales.php

示例3: 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;
 }
开发者ID:crunnells,项目名称:shopp,代码行数:13,代码来源:tax.php

示例4: 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;
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:20,代码来源:payment-types.php

示例5: 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;
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:21,代码来源:customers.php

示例6: 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;
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:23,代码来源:products.php

示例7: loader


//.........这里部分代码省略.........
         } else {
             $this->notice(sprintf(__('%d orders updated.', 'Shopp'), count($selected)));
         }
     }
     $Purchase = new ShoppPurchase();
     $offset = get_option('gmt_offset') * 3600;
     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);
     }
     $pagenum = absint($paged);
     $start = $per_page * ($pagenum - 1);
     $where = array();
     $joins = array();
     if (!empty($status) || $status === '0') {
         $where[] = "status='" . sDB::escape($status) . "'";
     }
     if (!empty($s)) {
         $s = stripslashes($s);
         $search = array();
         if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER) > 0) {
             foreach ($props as $query) {
                 $keyword = sDB::escape(!empty($query[2]) ? $query[2] : $query[3]);
                 switch (strtolower($query[1])) {
                     case "txn":
                         $search[] = "txnid='{$keyword}'";
                         break;
                     case "company":
                         $search[] = "company LIKE '%{$keyword}%'";
                         break;
                     case "gateway":
                         $search[] = "gateway LIKE '%{$keyword}%'";
                         break;
                     case "cardtype":
                         $search[] = "cardtype LIKE '%{$keyword}%'";
                         break;
                     case "address":
                         $search[] = "(address LIKE '%{$keyword}%' OR xaddress='%{$keyword}%')";
                         break;
                     case "city":
                         $search[] = "city LIKE '%{$keyword}%'";
                         break;
                     case "province":
                     case "state":
                         $search[] = "state='{$keyword}'";
                         break;
                     case "zip":
                     case "zipcode":
                     case "postcode":
                         $search[] = "postcode='{$keyword}'";
                         break;
                     case "country":
                         $search[] = "country='{$keyword}'";
                         break;
                     case "promo":
                     case "discount":
                         $meta_table = ShoppDatabaseObject::tablename(ShoppMetaObject::$table);
                         $joins[$meta_table] = "INNER JOIN {$meta_table} AS m ON m.parent = o.id AND context='purchase'";
                         $search[] = "m.value LIKE '%{$keyword}%'";
                         break;
                     case "product":
                         $purchased = ShoppDatabaseObject::tablename(Purchased::$table);
                         $joins[$purchased] = "INNER JOIN {$purchased} AS p ON p.purchase = o.id";
                         $search[] = "p.name LIKE '%{$keyword}%' OR p.optionlabel LIKE '%{$keyword}%' OR p.sku LIKE '%{$keyword}%'";
                         break;
                 }
             }
             if (empty($search)) {
                 $search[] = "(id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')";
             }
             $where[] = "(" . join(' OR ', $search) . ")";
         } elseif (strpos($s, '@') !== false) {
             $where[] = "email='" . sDB::escape($s) . "'";
         } else {
             $where[] = "(id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%" . sDB::escape($s) . "%')";
         }
     }
     if (!empty($starts) && !empty($ends)) {
         $where[] = "created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
     }
     if (!empty($customer)) {
         $where[] = "customer=" . intval($customer);
     }
     $where = !empty($where) ? "WHERE " . join(' AND ', $where) : '';
     $joins = join(' ', $joins);
     $countquery = "SELECT count(*) as total,SUM(IF(txnstatus IN ('authed','captured'),total,NULL)) AS sales,AVG(IF(txnstatus IN ('authed','captured'),total,NULL)) AS avgsale FROM {$Purchase->_table} AS o {$joins} {$where} ORDER BY o.created DESC LIMIT 1";
     $this->ordercount = sDB::query($countquery, 'object');
     $query = "SELECT o.* FROM {$Purchase->_table} AS o {$joins} {$where} ORDER BY created DESC LIMIT {$start},{$per_page}";
     $this->orders = sDB::query($query, 'array', 'index', 'id');
     $num_pages = ceil($this->ordercount->total / $per_page);
     if ($paged > 1 && $paged > $num_pages) {
         Shopp::redirect(add_query_arg('paged', null, $url));
     }
 }
开发者ID:jonathandavis,项目名称:shopp,代码行数:101,代码来源:Service.php

示例8: prepare

 /**
  * Prepares a ShoppDatabaseObject for entry into the database
  *
  * Iterates the properties of a ShoppDatabaseObject and formats the data
  * according to the datatype meta available for the property to create
  * an array of key/value pairs that are easy concatenate into a valid
  * SQL query
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @param ShoppDatabaseObject $Object The object to be prepared
  * @return array Data structure ready for query building
  **/
 public static function prepare($Object, array $mapping = array())
 {
     $data = array();
     // Go through each data property of the object
     $properties = get_object_vars($Object);
     foreach ($properties as $var => $value) {
         $property = isset($mapping[$var]) ? $mapping[$var] : $var;
         if (!isset($Object->_datatypes[$property])) {
             continue;
         }
         // If the property is has a _datatype
         // it belongs in the database and needs
         // to be prepared
         // Process the data
         switch ($Object->_datatypes[$property]) {
             case 'string':
                 // Escape characters in strings as needed
                 if (is_array($value) || is_object($value)) {
                     $data[$property] = "'" . addslashes(serialize($value)) . "'";
                 } else {
                     $data[$property] = "'" . sDB::escape($value) . "'";
                 }
                 break;
             case 'list':
                 // If value is empty, skip setting the field
                 // so it inherits the default value in the db
                 if (!empty($value)) {
                     $data[$property] = "'{$value}'";
                 }
                 break;
             case 'date':
                 // If it's an empty date, set it to the current time
                 if (is_null($value)) {
                     $value = current_time('mysql');
                     // If the date is an integer, convert it to an
                     // sql YYYY-MM-DD HH:MM:SS format
                 } elseif (!empty($value) && (is_int($value) || intval($value) > 86400)) {
                     $value = sDB::mkdatetime(intval($value));
                 }
                 $data[$property] = "'{$value}'";
                 break;
             case 'float':
                 // Sanitize without rounding to protect precision
                 if (is_string($value) && method_exists('ShoppCore', 'floatval')) {
                     $value = ShoppCore::floatval($value, false);
                 } else {
                     $value = floatval($value);
                 }
             case 'int':
                 // Normalize for MySQL float representations (@see bug #853)
                 // Force formating with full stop (.) decimals
                 // Trim excess 0's followed by trimming (.) when there is no fractional value
                 $value = rtrim(rtrim(number_format((double) $value, 6, '.', ''), '0'), '.');
                 $data[$property] = "'{$value}'";
                 if (empty($value)) {
                     $data[$property] = "'0'";
                 }
                 // Special exception for id fields
                 if ('id' == $property && empty($value)) {
                     $data[$property] = "NULL";
                 }
                 break;
             default:
                 // Anything not needing processing
                 // passes through into the structure
                 $data[$property] = "'{$value}'";
         }
     }
     return $data;
 }
开发者ID:crunnells,项目名称:shopp,代码行数:84,代码来源:DB.php

示例9: stats_widget

    /**
     * Renders the order stats widget
     *
     * @author Jonathan Davis
     * @since 1.0
     *
     * @return void
     **/
    public static function stats_widget($args = false)
    {
        $ranges = array('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'));
        $defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '', 'range' => isset($_GET['shopp-stats-range']) ? $_GET['shopp-stats-range'] : '');
        $args = array_merge($defaults, (array) $args);
        extract($args, EXTR_SKIP);
        if (!$range || !isset($ranges[strtolower($range)])) {
            $range = 'last30';
        }
        $purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
        $now = current_time('timestamp');
        // $offset = get_option( 'gmt_offset' ) * 3600;
        $daytimes = 86400;
        $day = date('j', $now);
        $month = date('n', $now);
        $year = date('Y', $now);
        $end = $now;
        list($weekstart, $weekend) = array_values(get_weekstartend(current_time('mysql')));
        switch ($range) {
            case 'today':
                $start = mktime(0, 0, 0, $month, $day, $year);
                break;
            case 'week':
                $start = $weekstart;
                $end = $weekend;
                break;
            case 'month':
                $start = mktime(0, 0, 0, $month, 1, $year);
                break;
            case 'quarter':
                $start = mktime(0, 0, 0, $month - (3 - $month % 3), 1, $year);
                break;
            case 'year':
                $start = mktime(0, 0, 0, 1, 1, $year);
                break;
            case 'yesterday':
                $start = mktime(0, 0, 0, $month, $day - 1, $year);
                $end = mktime(23, 59, 59, $month, $day - 1, $year);
                break;
            case 'lastweek':
                $start = $weekstart - 7 * $daytimes;
                $end = $weekstart - 1;
                break;
            case 'last7':
                $start = $now - 7 * $daytimes;
                break;
            case 'last30':
                $start = $now - 30 * $daytimes;
                break;
            case 'last90':
                $start = $now - 90 * $daytimes;
                break;
            case 'lastmonth':
                $start = mktime(0, 0, 0, $month - 1, 1, $year);
                $end = mktime(0, 0, 0, $month, 0, $year);
                break;
            case 'lastquarter':
                $start = mktime(0, 0, 0, $month - (3 - $month % 3) - 3, 1, $year);
                $end = mktime(23, 59, 59, date('n', $start) + 3, 0, $year);
                break;
            case 'lastyear':
                $start = mktime(0, 0, 0, $month, 1, $year - 1);
                $end = mktime(23, 59, 59, 1, 0, $year);
                break;
        }
        // Include authorizations, captures and old 1.1 tranaction status CHARGED in sales data
        $salestatus = array("'authed'", "'captured'", "'CHARGED'");
        $txnstatus = "txnstatus IN (" . join(',', $salestatus) . ")";
        $daterange = "created BETWEEN '" . sDB::mkdatetime($start) . "' AND '" . sDB::mkdatetime($end) . "'";
        $query = "SELECT count(id) AS orders,\n\t\t\t\t\t\tSUM(total) AS sales,\n\t\t\t\t\t\tAVG(total) AS average,\n\t\t \t\t\t\tSUM(IF({$daterange},1,0)) AS wkorders,\n\t\t\t\t\t\tSUM(IF({$daterange},total,0)) AS wksales,\n\t\t\t\t\t\tAVG(IF({$daterange},total,null)) AS wkavg\n \t\t\t\t\tFROM {$purchasetable} WHERE {$txnstatus}";
        $cached = get_transient('shopp_dashboard_stats_' . $range);
        if (empty($cached)) {
            $results = sDB::query($query);
            $RecentBestsellers = new BestsellerProducts(array('range' => array($start, $end), 'show' => 5));
            $RecentBestsellers->load(array('pagination' => false));
            $RecentBestsellers->maxsold = 0;
            foreach ($RecentBestsellers as $product) {
                $RecentBestsellers->maxsold = max($RecentBestsellers->maxsold, $product->sold);
            }
            $LifeBestsellers = new BestsellerProducts(array('show' => 5));
            $LifeBestsellers->load(array('pagination' => false));
            $LifeBestsellers->maxsold = 0;
            foreach ($LifeBestsellers as $product) {
                $LifeBestsellers->maxsold = max($LifeBestsellers->maxsold, $product->sold);
            }
            set_transient('shopp_dashboard_stats_' . $range, array($results, $RecentBestsellers, $LifeBestsellers), 300);
        } else {
            list($results, $RecentBestsellers, $LifeBestsellers) = $cached;
        }
        echo $before_widget;
        echo $before_title;
        echo $widget_name;
//.........这里部分代码省略.........
开发者ID:forthrobot,项目名称:inuvik,代码行数:101,代码来源:Dashboard.php

示例10: publishset

 /**
  * Sets the status of a set of products
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param array $ids Set of product IDs to update
  * @param string $status The status to set: publish, draft, trash
  * @return boolean
  **/
 static function publishset(array $ids, $status)
 {
     if (empty($ids) || !is_array($ids)) {
         return false;
     }
     $settings = array('publish', 'draft', 'trash');
     if (!in_array($status, $settings)) {
         return false;
     }
     $table = WPShoppObject::tablename(self::$table);
     $time = current_time('timestamp');
     $post_date_gmt = sDB::mkdatetime($time + get_option('gmt_offset') * 3600);
     $post_date = sDB::mkdatetime($time);
     sDB::query("UPDATE {$table} SET post_status='{$status}', post_date='{$post_date}', post_date_gmt='{$post_date_gmt}', post_modified='{$post_date}', post_modified_gmt='{$post_date_gmt}' WHERE ID in (" . join(',', $ids) . ")");
     foreach ($ids as $id) {
         // Recount taxonomy counts #2968
         $Post = get_post($id);
         switch ($status) {
             case 'trash':
                 do_action('wp_trash_post', $id);
                 break;
             default:
                 do_action('save_post', $id, $Post);
                 break;
         }
         if (function_exists('clean_post_cache')) {
             clean_post_cache($id);
         }
         wp_transition_post_status($status, $Product->status, $Post);
     }
     return true;
 }
开发者ID:jonathandavis,项目名称:shopp,代码行数:42,代码来源:Product.php

示例11: smart

 public function smart(array $options = array())
 {
     if (isset($options['range']) && is_array($options['range'])) {
         $start = $options['range'][0];
         $end = $options['range'][1];
         if (!$end) {
             $end = current_time('timestamp');
         }
         $purchased = ShoppDatabaseObject::tablename(Purchased::$table);
         $this->loading['columns'] = "COUNT(*) AS sold";
         $this->loading['joins'] = array($purchased => "INNER JOIN {$purchased} as pur ON pur.product=p.id");
         $this->loading['where'] = array("pur.created BETWEEN '" . sDB::mkdatetime($start) . "' AND '" . sDB::mkdatetime($end) . "'");
         $this->loading['orderby'] = 'sold DESC';
         $this->loading['groupby'] = 'pur.product';
     } else {
         $this->loading['where'] = array(BestsellerProducts::threshold() . " < s.sold");
         $this->loading['order'] = 'bestselling';
         // Use overall bestselling stats
         $this->loading = array_merge($options, $this->loading);
     }
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:21,代码来源:Collection.php

示例12: prepare_items

 public function prepare_items()
 {
     $defaults = array('page' => false, 'deleting' => false, 'selected' => false, 'update' => false, 'newstatus' => false, 'pagenum' => 1, 'paged' => 1, 'per_page' => 20, 'start' => '', 'end' => '', 'status' => false, 's' => '', 'range' => '', 'startdate' => '', 'enddate' => '');
     $args = array_merge($defaults, $this->request());
     extract($args, EXTR_SKIP);
     // $url = $this->url($_GET);
     $statusLabels = shopp_setting('order_status');
     if (empty($statusLabels)) {
         $statusLabels = array('');
     }
     $txnstatus_labels = Lookup::txnstatus_labels();
     $Purchase = new ShoppPurchase();
     $offset = get_option('gmt_offset') * 3600;
     if ($this->request('start')) {
         list($month, $day, $year) = explode("/", $this->request('start'));
         $starts = mktime(0, 0, 0, $month, $day, $year);
     }
     if ($this->request('end')) {
         list($month, $day, $year) = explode("/", $this->request('end'));
         $ends = mktime(23, 59, 59, $month, $day, $year);
     }
     $pagenum = absint($paged);
     $start = $per_page * ($pagenum - 1);
     $where = array();
     $joins = array();
     if (!empty($status) || '0' === $status) {
         $where[] = "status='" . sDB::escape($status) . "'";
     }
     if (!empty($s)) {
         $s = stripslashes($s);
         $search = array();
         if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER) > 0) {
             foreach ($props as $query) {
                 $keyword = sDB::escape(!empty($query[2]) ? $query[2] : $query[3]);
                 switch (strtolower($query[1])) {
                     case "txn":
                         $search[] = "txnid='{$keyword}'";
                         break;
                     case "company":
                         $search[] = "company LIKE '%{$keyword}%'";
                         break;
                     case "gateway":
                         $search[] = "gateway LIKE '%{$keyword}%'";
                         break;
                     case "cardtype":
                         $search[] = "cardtype LIKE '%{$keyword}%'";
                         break;
                     case "address":
                         $search[] = "(address LIKE '%{$keyword}%' OR xaddress='%{$keyword}%')";
                         break;
                     case "city":
                         $search[] = "city LIKE '%{$keyword}%'";
                         break;
                     case "province":
                     case "state":
                         $search[] = "state='{$keyword}'";
                         break;
                     case "zip":
                     case "zipcode":
                     case "postcode":
                         $search[] = "postcode='{$keyword}'";
                         break;
                     case "country":
                         $search[] = "country='{$keyword}'";
                         break;
                     case "promo":
                     case "discount":
                         $meta_table = ShoppDatabaseObject::tablename(ShoppMetaObject::$table);
                         $joins[$meta_table] = "INNER JOIN {$meta_table} AS m ON m.parent = o.id AND context='purchase'";
                         $search[] = "m.value LIKE '%{$keyword}%'";
                         break;
                     case "product":
                         $purchased = ShoppDatabaseObject::tablename(Purchased::$table);
                         $joins[$purchased] = "INNER JOIN {$purchased} AS p ON p.purchase = o.id";
                         $search[] = "p.name LIKE '%{$keyword}%' OR p.optionlabel LIKE '%{$keyword}%' OR p.sku LIKE '%{$keyword}%'";
                         break;
                 }
             }
             if (empty($search)) {
                 $search[] = "(id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')";
             }
             $where[] = "(" . join(' OR ', $search) . ")";
         } elseif (strpos($s, '@') !== false) {
             $where[] = "email='" . sDB::escape($s) . "'";
         } else {
             $where[] = "(id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%" . sDB::escape($s) . "%')";
         }
     }
     if (!empty($starts) && !empty($ends)) {
         $where[] = "created BETWEEN '" . sDB::mkdatetime($starts) . "' AND '" . sDB::mkdatetime($ends) . "'";
     }
     if (!empty($customer)) {
         $where[] = "customer=" . intval($customer);
     }
     $where = !empty($where) ? "WHERE " . join(' AND ', $where) : '';
     $joins = join(' ', $joins);
     $countquery = "SELECT count(*) as total,SUM(IF(txnstatus IN ('authed','captured'),total,NULL)) AS sales,AVG(IF(txnstatus IN ('authed','captured'),total,NULL)) AS avgsale FROM {$Purchase->_table} AS o {$joins} {$where} ORDER BY o.created DESC LIMIT 1";
     $this->ordercount = sDB::query($countquery, 'object');
     $query = "SELECT o.* FROM {$Purchase->_table} AS o {$joins} {$where} ORDER BY created DESC LIMIT {$start},{$per_page}";
     $this->items = sDB::query($query, 'array', 'index', 'id');
//.........这里部分代码省略.........
开发者ID:msigley,项目名称:shopp,代码行数:101,代码来源:Orders.php

示例13: maintenance

 /**
  * Post activation maintenance
  *
  * @author Jonathan Davis
  * @since 1.2.6
  *
  * @return void
  **/
 function maintenance()
 {
     global $wpdb;
     $db_version = ShoppSettings::dbversion();
     if ($db_version <= 1149) {
         // Set mass packaging setting to 'all' for current realtime shipping rates {@see bug #1835}
         if ('mass' == shopp_setting('shipping_packaging')) {
             shopp_set_setting('shipping_packaging', 'all');
         }
         // Fix all product modified timestamps (for 1.2.6)
         $post_type = 'shopp_product';
         $post_modified = sDB::mkdatetime(current_time('timestamp'));
         $post_modified_gmt = sDB::mkdatetime(current_time('timestamp') + get_option('gmt_offset') * 3600);
         sDB::query("UPDATE {$wpdb->posts} SET post_modified='{$post_modified}', post_modified_gmt='{$post_modified_gmt}' WHERE post_type='{$post_type}' AND post_modified='0000-00-00 00:00:00'");
     }
 }
开发者ID:crunnells,项目名称:shopp,代码行数:24,代码来源:Install.php

示例14: publishset

 /**
  * Sets the status of a set of products
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param array $ids Set of product IDs to update
  * @param string $status The status to set: publish, draft, trash
  * @return boolean
  **/
 static function publishset(array $ids, $status)
 {
     if (empty($ids) || !is_array($ids)) {
         return false;
     }
     $settings = array('publish', 'draft', 'trash');
     if (!in_array($status, $settings)) {
         return false;
     }
     $table = WPShoppObject::tablename(self::$table);
     $time = current_time('timestamp');
     $post_date_gmt = sDB::mkdatetime($time + get_option('gmt_offset') * 3600);
     $post_date = sDB::mkdatetime($time);
     sDB::query("UPDATE {$table} SET post_status='{$status}', post_date='{$post_date}', post_date_gmt='{$post_date_gmt}', post_modified='{$post_date}', post_modified_gmt='{$post_date_gmt}' WHERE ID in (" . join(',', $ids) . ")");
     foreach ($ids as $id) {
         // Recount taxonomy counts #2968
         $laststatus = get_post_status($id);
         $Post = new StdClass();
         $Post->ID = $id;
         $Post->post_type = ShoppProduct::$posttype;
         wp_transition_post_status($status, $laststatus, $Post);
     }
     return true;
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:34,代码来源:Product.php


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