public function execute() { $lazy = waRequest::get('lazy', 0, waRequest::TYPE_INT); $offset = waRequest::get('offset', 0, waRequest::TYPE_INT); $limit = 30; $model = new shopDiscountcardsPluginModel(); $sql = "SELECT count(*) " . $this->getSql(); $total_count = (int) $model->query($sql)->fetchField(); $sql = "SELECT * " . $this->getSql() . " LIMIT {$offset}, {$limit}"; $discountcards = $model->query($sql)->fetchAll(); foreach ($discountcards as &$discountcard) { if (!empty($discountcard['contact_id'])) { $discountcard['contact'] = new waContact($discountcard['contact_id']); try { $discountcard['contact']->load(); } catch (Exception $ex) { unset($discountcard['contact']); } } } $this->view->assign(array('discountcards' => $discountcards, 'offset' => $offset, 'limit' => $limit, 'count' => count($discountcards), 'total_count' => $total_count, 'lazy' => $lazy)); }