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


PHP Accounts::findFirst方法代码示例

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


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

示例1: createAction

 public function createAction()
 {
     $this->view->disable();
     $status = "OK";
     $params = json_decode(file_get_contents('php://input'));
     $model = Accounts::findFirst("name='{$params->name}'");
     if ($model == null) {
         $model = new Accounts();
         $model->group = $params->group;
         $model->name = $params->name;
         $model->email = $params->email;
         $model->pm = $params->pm;
         $model->save();
     }
     echo json_encode(array("status" => $status));
 }
开发者ID:vietdh85,项目名称:vh-utility,代码行数:16,代码来源:AccountsController.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

示例3: getChatUsersAction

 /**
  * Get a list of users in a group chat
  */
 public function getChatUsersAction()
 {
     $this->ajaxCheck();
     $chat_id = $this->request->get('chat_id');
     $users = [];
     foreach (SChats::find(["chat_id={$chat_id}", 'columns' => 'user_id']) as $chat) {
         $account = Accounts::findFirst(["id={$chat->user_id}", 'columns' => 'id, name']);
         $users[] = ['id' => $account->id, 'name' => $account->name, 'status' => SOnlineStatus::findFirst($account->id) ? 1 : 0];
     }
     echo json_encode($users);
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:14,代码来源:ChatController.php

示例4: createInvestAction

 public function createInvestAction()
 {
     $this->view->disable();
     $status = "NG";
     $params = json_decode(file_get_contents('php://input'));
     $model = new SiteInvests();
     $model->site_id = $params->site_id;
     $model->monitor = $params->monitor;
     $model->acc_name = $params->acc_name;
     $model->amount = $params->amount;
     $model->ip = $params->ip;
     $model->time = $params->time;
     $model->status = "Invest";
     if ($model->save()) {
         $account = Accounts::findFirst("name='{$params->acc_name}'");
         $account->amount -= $params->amount;
         $account->save();
         $status = "OK";
     }
     echo json_encode(array("status" => $status));
 }
开发者ID:vietdh85,项目名称:vh-utility,代码行数:21,代码来源:HyipsController.php


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