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


PHP Marketplace::find方法代码示例

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


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

示例1: marketplacesAction

 public function marketplacesAction()
 {
     // All marketplaces
     $marketplaces = Marketplace::find(["active = 1", 'order' => 'title ASC']);
     $this->view->marketplaces = $marketplaces;
     // All langs
     $langs = PProdInfo::count(['group' => 'lang', 'order' => 'id']);
     foreach ($langs as $lang) {
         $langs_array[] = $lang->lang;
     }
     $this->view->langs = $this->persistent->langs = $langs_array;
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:12,代码来源:SellerController.php

示例2: stats

 /**
  * Common function for gathering stats
  *
  * @param string $input_role - user role
  * @param string $selspec - identificator for various types of seller stats (marketplaces, lang)
  */
 private function stats($input_role = null, $selspec = null)
 {
     // If there is no role specified this is a regular type of stats (phorocoder, translators, moderators...)
     $user_roles = $input_role == null ? $this->user_roles : $input_role;
     $months = $this->months;
     $days_ru = $this->days_ru;
     $month_and_year = date('m.Y', time());
     // Current month and year
     // Change month and year to ones selected by user
     if ($this->request->isPost() && !empty($this->request->getPost('month_and_year', 'string'))) {
         $month_and_year = $this->request->getPost('month_and_year', 'string');
     }
     $first_day_of_month = strtotime("01.{$month_and_year}");
     $first_day_of_next_month = strtotime("01.{$month_and_year} + 1 month");
     $num_of_days = (int) (($first_day_of_next_month - $first_day_of_month) / 86400);
     // Number of days in the month
     // Array of days in the selected month in unix timestamp
     for ($i = 1; $i <= $num_of_days; $i++) {
         $days[] = strtotime("{$i}.{$month_and_year}");
     }
     $days[] = $first_day_of_next_month;
     // Find stats for a month
     // photocoder, copywriter/moder, translator/moder
     if ($input_role == null) {
         $tasks = new PTasks();
         // @todo remove + 7200 !!!!!!!!!!!!!!!! set db server to correct time
         $sql = "SELECT COUNT(t1.id) AS count, FROM_UNIXTIME(t1.tstart + 7200, '%Y-%m-%d') AS cdate, t1.tstart, t1.trole, t1.tlang, t1.tassignee, t1.tprodid\n                    FROM p_tasks AS t1\n                    WHERE t1.tstart BETWEEN {$first_day_of_month} AND {$first_day_of_next_month} AND (t1.tstatus = 3 OR t1.tstatus = 5)\n                    GROUP BY t1.trole, t1.tlang, t1.tassignee, t1.tprodid, cdate\n                    ORDER BY t1.tassignee DESC;";
         $stats = new Resultset(null, $tasks, $tasks->getReadConnection()->query($sql));
         $stats = $stats->toArray();
         // seller
     } elseif ($input_role == 'seller') {
         $field = "user_id";
         if ($selspec == 'mplace') {
             $field = "marketplace_id";
         }
         // Marketplaces stats
         if ($selspec == 'lang') {
             $field = "langcode";
         }
         // Langs stats
         $tasks = new MPlacement();
         $sql = "SELECT COUNT(mp.id) AS count, FROM_UNIXTIME(mp.created + 7200, '%Y-%m-%d') AS cdate, mp.created, mp.user_id, mp.marketplace_id, mp.langcode\n                    FROM mplacement AS mp\n                    WHERE mp.created BETWEEN {$first_day_of_month} AND {$first_day_of_next_month}\n                    GROUP BY mp.{$field}, cdate\n                    ORDER BY mp.{$field}, cdate";
         $stats = new Resultset(null, $tasks, $tasks->getReadConnection()->query($sql));
         $stats = $stats->toArray();
     }
     // Find regular sellers and APIs
     if ($input_role == 'seller' && $selspec == null) {
         $all_sellers = Accounts::getUsersByRole('seller', false, 'name');
         $this->view->regular_sellers = $regular_sellers = preg_grep('/^(?!API)/', $all_sellers);
         $this->view->api_sellers = $api_sellers = preg_grep('/^API/', $all_sellers);
     }
     // All marketplaces
     if ($input_role == 'seller' && $selspec == 'mplace') {
         $all_marketplaces = array_column(Marketplace::find(['columns' => 'title, id', 'order' => 'title'])->toArray(), 'title', 'id');
     }
     // All langs
     if ($input_role == 'seller' && $selspec == 'lang') {
         $all_langs = array_column(PLangs::find(['columns' => 'alias', 'order' => 'id'])->toArray(), 'alias', 'alias');
     }
     $roles = [];
     $assignee = [];
     foreach ($stats as $stat) {
         // Regular stats
         if ($input_role == null) {
             $roles[$stat['trole']][$stat['tlang']][$stat['tassignee']][] = $stat['tstart'];
             // Seller stats
         } elseif ($input_role == 'seller' && $selspec == null) {
             $seller_stats[$stat['user_id']][$stat['cdate']] = (int) $stat['count'];
             // Seller marketplaces stats
         } elseif ($input_role == 'seller' && $selspec == 'mplace') {
             $seller_stats[$stat['marketplace_id']][$stat['cdate']] = (int) $stat['count'];
             // Seller langs stats
         } elseif ($input_role == 'seller' && $selspec == 'lang') {
             $seller_stats[$stat['langcode']][$stat['cdate']] = (int) $stat['count'];
         }
         // Link user_id to his name if it's not already linked
         // Regular stats
         if ($input_role == null) {
             if (empty($assignee[$stat['tassignee']])) {
                 if ($acc_name = Accounts::findFirst($stat['tassignee'])) {
                     $assignee[$stat['tassignee']] = $acc_name->name;
                 }
             }
             // Seller stats
         } elseif ($input_role == 'seller' && $selspec == null) {
             if (empty($assignee[$stat['user_id']])) {
                 foreach ($all_sellers as $seller_id => $seller_name) {
                     if ($stat['user_id'] == $seller_id) {
                         $assignee[$stat['user_id']] = $seller_name;
                     }
                 }
             }
             // Seller marketplaces stats
         } elseif ($input_role == 'seller' && $selspec == 'mplace') {
//.........这里部分代码省略.........
开发者ID:serge2300,项目名称:madeheart,代码行数:101,代码来源:StatController.php


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