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


PHP Context::table方法代码示例

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


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

示例1: renderDefault

 public function renderDefault()
 {
     $id = '4';
     $this->template->program = $this->database->table('posts')->order('created_at DESC')->where('id = ?', $id);
     $title = $this->database->table('posts')->get($id);
     $this->template->titulek = $title['title'];
 }
开发者ID:pzdesign,项目名称:statekbenatky-nette,代码行数:7,代码来源:ProgramPresenter.php

示例2: create

 /**
  * @return Form
  */
 public function create($role)
 {
     $rights = $this->database->table('rights')->fetchPairs('id', 'name');
     $form = new Form();
     $form->addHidden('id');
     $form->addText('username', 'uživatelské jméno: ')->addRule(Form::FILLED, 'Zadejte prosím jméno.');
     $form->addText('email', 'email: ')->addRule(Form::FILLED, 'Zadejte prosím email.')->addRule(Form::EMAIL, 'Email by měl mít platný formát');
     if (in_array("admin", $role)) {
         // editace prav jen adminem
         $form->addSelect('rights_id', 'level práv: ', $rights);
     }
     $form->addSubmit('submit', 'uložit');
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     //bootstrap vzhled
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['container'] = '';
     $renderer->wrappers['label']['container'] = 'div class="control-label col-sm-5"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     $form->getElementPrototype()->class('form-horizontal col-sm-12');
     return $form;
 }
开发者ID:JakubMarden,项目名称:bazenycz,代码行数:28,代码来源:userEditFormFactory.php

示例3: addQuestion

 public function addQuestion($data)
 {
     if ($data) {
         return $this->database->table('questions')->insert($data);
     }
     return false;
 }
开发者ID:Vesely,项目名称:rocnikac,代码行数:7,代码来源:Questions.php

示例4: createComponentGrid

 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->model = $this->database->table('user');
     $grid->addColumnText('firstname', 'Firstname')->setFilterText()->setSuggestion();
     $grid->addColumnText('surname', 'Surname')->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText('gender', 'Gender')->setSortable()->cellPrototype->class[] = 'center';
     $grid->addColumnDate('birthday', 'Birthday', \Grido\Components\Columns\Date::FORMAT_TEXT)->setSortable()->setFilterDate()->setCondition($grid->birthdayFilterCondition);
     $grid->getColumn('birthday')->cellPrototype->class[] = 'center';
     $templatePath = "{$this->context->parameters['appDir']}/templates/{$this->name}";
     $renderer = function ($row) {
         return $row->country->title;
     };
     $grid->addColumnText('country', 'Country')->setSortable()->setColumn('country.title')->setCustomRender("{$templatePath}/grid.country.latte")->setCustomRenderExport($renderer)->setFilterText()->setSuggestion($renderer);
     $grid->addColumnText('card', 'Card')->setSortable()->setColumn('cctype')->setReplacement(array('MasterCard' => Html::el('b')->setText('MasterCard')))->cellPrototype->class[] = 'center';
     $grid->addColumnEmail('emailaddress', 'Email')->setSortable()->setFilterText();
     $grid->getColumn('emailaddress')->cellPrototype->class[] = 'center';
     $grid->addColumnText('centimeters', 'Height')->setSortable()->setFilterNumber();
     $grid->getColumn('centimeters')->cellPrototype->class[] = 'center';
     $grid->addFilterSelect('gender', 'Gender', array('' => '', 'female' => 'female', 'male' => 'male'));
     $grid->addFilterSelect('card', 'Card', array('' => '', 'MasterCard' => 'MasterCard', 'Visa' => 'Visa'))->setColumn('cctype');
     $grid->addFilterCheck('preferred', 'Only preferred girls :)')->setCondition(array(TRUE => array(array('gender', 'AND', 'centimeters'), array('= ?', '>= ?'), array('female', 170))));
     $grid->addActionHref('edit', 'Edit')->setIcon('pencil');
     $grid->addActionHref('delete', 'Delete')->setIcon('trash')->setConfirm(function ($item) {
         return "Are you sure you want to delete {$item->firstname} {$item->surname}?";
     });
     $operation = array('print' => 'Print', 'delete' => 'Delete');
     $grid->setOperation($operation, $this->handleOperations)->setConfirm('delete', 'Are you sure you want to delete %i items?');
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
 }
开发者ID:o5,项目名称:grido-examples,代码行数:31,代码来源:NetteDatabasePresenter.php

示例5: startup

 protected function startup()
 {
     parent::startup();
     // Login check
     if ($this->getName() != 'Admin:Sign') {
         $role = $this->user->getRoles();
         $roleCheck = $this->database->table("users_roles")->get($role[0]);
         if ($roleCheck->admin_access == 0) {
             $this->flashMessage($this->translator->translate('messages.sign.invalidLogin'), "error");
             $this->redirect(':Admin:Sign:in');
         }
         if ($this->user->isLoggedIn()) {
         } else {
             if ($this->user->logoutReason === Nette\Security\IUserStorage::INACTIVITY) {
                 $this->flashMessage($this->translator->translate('messages.sign.youWereLoggedIn'), "note");
             }
             $this->redirect('Sign:in', array('backlink' => $this->storeRequest()));
         }
     }
     if ($this->user->isLoggedIn()) {
         $this->template->isLoggedIn = TRUE;
         $this->template->member = $this->database->table("users")->get($this->user->getId());
     }
     // Set values from db
     $this->template->settings = $this->database->table("settings")->fetchPairs("setkey", "setvalue");
     $this->template->appDir = APP_DIR;
     $this->template->signed = TRUE;
     $this->template->langSelected = $this->translator->getLocale();
     // Set language from cookie
     if ($this->context->httpRequest->getCookie('language_admin') == '') {
         $this->translator->setLocale($this->translator->getDefaultLocale());
     } else {
         $this->translator->setLocale($this->context->httpRequest->getCookie('language_admin'));
     }
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:35,代码来源:BasePresenter.php

示例6: renderDefault

 public function renderDefault()
 {
     // 1. Vlozeni noveho zaznamu do tabulky se zavody
     // 2. Vyber zavodu (identifikatoru), vetsinou toho, ktery byl vytvoren v predchozim bode
     $id_event = "VCHOD2015";
     // 3. Kontrola identifikatoru zavodu - nesmi byt pouzit v tabulce casu
     $data = $this->database->query('select id from sm_time where id_event = ?', $id_event);
     if ($data->getRowCount() > 0) {
         // Chyba! Vyzadovat novou volbu zavodu
         // Pozor! VCHOD2015 jiz v tabulce casu je!
     }
     // 4. Zadani textoveho souboru s vysledky s predepsanym DR
     //        $input_file = "/home/vencs88/php/import_time/data/cp_praha2015.txt";
     //        $input_file = "/home/vencs88/php/import_time/data/vysledky_blbec.txt";
     $input_file = "/home/vencs88/php/import_time/data/mem2015.txt";
     // 5. Vizualni kontrola chyb po nacteni vysledku do pomocne tabulky
     $this->template->status = $this->importTimeManager->getImportData($input_file, $id_event);
     $this->template->data = $this->database->table('sm_import');
     // 6. Nejsou-li chyby, umoznit import vysledku do tabulky casu
     //        INSERT INTO sm_time
     //            (
     //                id_stroke,
     //                id_swimmer,
     //                time,
     //                rank,
     //                point
     //            )
     //            SELECT * FROM sm_import;
     //
     //        // Zvazit vymaz pomocne tabulky
     //        DELETE FROM sm_import;
 }
开发者ID:jabahad,项目名称:importTime,代码行数:32,代码来源:HomepagePresenter.php

示例7: startup

 public function startup()
 {
     try {
         $id = $this->getParameter('id');
         if ($id !== NULL && ($id = $this->isValidId($id)) === FALSE) {
             throw BadRequestException::methodNotSupported('Url must follow convention /presenter/id/relation/relationId.' . ' Valid ID is only positive, non zero integer.');
         }
         $action = $this->getAction();
         if ($action === 'create' && $id) {
             $this->changeAction('update');
         }
         parent::startup();
         if (strpos($action, 'read') === FALSE) {
             $this->inputData = $this->inputData ?: $this->getInputData();
         }
         if (($relation = $this->getParameter('relation')) !== NULL) {
             $this->table = $this->db->table($relation)->where($this->getTableName(), $id);
             $this->deepListing = $this->queryFilter = NULL;
         } else {
             $this->table = $this->db->table($this->getTableName());
         }
     } catch (BadRequestException $ex) {
         $this->sendErrorResource($ex);
     }
 }
开发者ID:klajmajk,项目名称:futro,代码行数:25,代码来源:BasePresenter.php

示例8: parseSnippets

 public function parseSnippets($s)
 {
     preg_match_all("/\\[snippet\\=\"([0-9]{1,10})\"\\]/s", $s, $valsimp, PREG_SET_ORDER);
     if (count($valsimp) > 0) {
         for ($n = 0; $n < count($valsimp); $n++) {
             $snippet = $this->database->table("snippets")->get($valsimp[$n][1]);
             if ($snippet) {
                 if ($this->presenter->translator->getLocale() == $this->presenter->translator->getDefaultLocale()) {
                     $results = $snippet->content;
                 } else {
                     $results = $snippet->{'content_' . $this->presenter->translator->getLocale()};
                 }
             } else {
                 $results = null;
             }
             $s = str_replace($valsimp[$n][0], "{$results}", $s);
         }
     }
     preg_match_all("/\\[file\\=([0-9]{1,10})\\]/s", $s, $valsimp, PREG_SET_ORDER);
     if (count($valsimp) > 0) {
         for ($n = 0; $n < count($valsimp); $n++) {
             $snippet = $this->database->table("media")->get($valsimp[$n][1]);
             if ($snippet) {
                 $results = '/media/' . $snippet->pages_id . '/' . $snippet->name;
             } else {
                 $results = null;
             }
             $s = str_replace($valsimp[$n][0], "{$results}", $s);
         }
     }
     return $s;
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:32,代码来源:PageDocumentControl.php

示例9: editEventFormSucceeded

 function editEventFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $values = $form->getHttpData($form::DATA_TEXT);
     $date_start = \DateTime::createFromFormat('j. n. Y', $form->values->date_event);
     $date1 = $date_start->format('Y-m-d');
     $date_start = \DateTime::createFromFormat('j. n. Y', $form->values->date_event_end);
     $date2 = $date_start->format('Y-m-d');
     if ($form->values->date_event == '') {
         $dateEvent = null;
     } else {
         if ($form->values->allday) {
             $dateEvent = $date1 . ' 00:00:00';
         } else {
             $dateEvent = $date1 . ' ' . $values["hour_event"] . ':' . $values["minute_event"];
         }
     }
     if ($form->values->date_event_end == '') {
         $dateEventEnd = null;
     } else {
         if ($form->values->allday) {
             $dateEventEnd = $date2 . ' 23:55:00';
         } else {
             $dateEventEnd = $date2 . ' ' . $values["hour_event_end"] . ':' . $values["minute_event_end"];
         }
     }
     $arr = array("date_event" => $dateEvent, "date_event_end" => $dateEventEnd, "all_day" => $form->values->allday, "price" => $form->values->price, "capacity" => $form->values->capacity, "capacity_start" => $form->values->capacity_start, "time_range" => $form->values->time_range);
     if ($form->values->contact) {
         $arr["contacts_id"] = $form->values->contact;
     }
     $this->database->table("events")->get($form->values->event_id)->update($arr);
     $this->presenter->redirect(":Admin:Events:detail", array("id" => $form->values->id));
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:32,代码来源:EditEventControl.php

示例10: createComponentCarouselGrid

 public function createComponentCarouselGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     $test = $this->database->table("carousel")->order("sorted");
     $grid->setDataSource($test);
     $grid->setSortable(true);
     $grid->addGroupAction('Smazat')->onSelect[] = [$this, 'handleDelete'];
     $grid->addColumnText('title', 'dictionary.main.Title')->setRenderer(function ($item) {
         if ($item->title == '') {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText('- nemá název - ');
         } else {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText($item->title);
         }
         return $title;
     });
     $grid->addColumnText('test', 'dictionary.main.Image')->setRenderer(function ($item) {
         if ($item->image == '') {
             $fileImage = '';
         } else {
             $fileImage = \Nette\Utils\Html::el('img', array('style' => 'max-height: 130px;'))->src('/images/carousel/' . $item->image);
         }
         return $fileImage;
     });
     $grid->setTranslator($this->presenter->translator);
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:25,代码来源:CarouselGridControl.php

示例11: addTestResult

 public function addTestResult($data)
 {
     if ($data) {
         return $this->database->table('test_results')->insert($data);
     }
     return false;
 }
开发者ID:Vesely,项目名称:rocnikac,代码行数:7,代码来源:TestResults.php

示例12: updateAddon

 private function updateAddon(ActiveRow $addon)
 {
     $this->writeln('Updating: ' . $addon->name);
     $github = $this->normalizeGithubUrl($addon->repository);
     if ($github) {
         $guzzle = new \Guzzle\Http\Client();
         try {
             $guzzle->get($github)->send();
             $this->db->table('addons_resources')->insert(array('addonId' => $addon->id, 'type' => 'github', 'resource' => $github));
         } catch (\Guzzle\Http\Exception\RequestException $e) {
             $this->writeln((string) $e);
         }
     }
     if ($addon->type === 'composer') {
         $version = $addon->related('versions')->order('id', 'DESC')->fetch();
         $composerData = Json::decode($version->composerJson);
         $packagist = $this->generatePackagistUrl($composerData->name);
         $guzzle = new \Guzzle\Http\Client();
         try {
             $guzzle->get($packagist . '.json')->send();
             $this->db->table('addons_resources')->insert(array('addonId' => $addon->id, 'type' => 'packagist', 'resource' => $packagist));
         } catch (\Guzzle\Http\Exception\RequestException $e) {
             $this->writeln((string) $e);
         }
     }
     if ($addon->demo) {
         $guzzle = new \Guzzle\Http\Client();
         try {
             $guzzle->get($addon->demo)->send();
             $this->db->table('addons_resources')->insert(array('addonId' => $addon->id, 'type' => 'demo', 'resource' => $addon->demo));
         } catch (\Guzzle\Http\Exception\RequestException $e) {
             $this->writeln((string) $e);
         }
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:35,代码来源:ResourcesPresenter.php

示例13: render

 public function render()
 {
     $template = $this->template;
     $template->languages = $this->database->table("languages")->where("default", null);
     $template->setFile(__DIR__ . '/EditMenuControl.latte');
     $template->render();
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:7,代码来源:EditMenuControl.php

示例14: authenticate

 public function authenticate(array $credentials)
 {
     $mcrypt = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
     $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($mcrypt), MCRYPT_DEV_RANDOM);
     mcrypt_generic_init($mcrypt, $this->cryptPassword, $iv);
     $url = $this->getUrl($credentials[self::USERNAME], $credentials[self::PASSWORD], $mcrypt, $iv);
     try {
         $res = $this->httpClient->get($url)->send();
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
         if ($e->getResponse()->getStatusCode() === 403) {
             throw new \Nette\Security\AuthenticationException("User '{$credentials[self::USERNAME]}' not found.", self::INVALID_CREDENTIAL);
         } elseif ($e->getResponse()->getStatusCode() === 404) {
             throw new \Nette\Security\AuthenticationException("Invalid password.", self::IDENTITY_NOT_FOUND);
         } else {
             throw $e;
         }
     }
     $responseBody = trim(mdecrypt_generic($mcrypt, $res->getBody(TRUE)));
     $apiData = Json::decode($responseBody);
     $user = $this->db->table('users')->where('id = ?', $apiData->id)->fetch();
     $registered = new \DateTimeImmutable($apiData->registered->date, new \DateTimeZone($apiData->registered->timezone));
     $userData = array('username' => $credentials[self::USERNAME], 'password' => $this->calculateAddonsPortalPasswordHash($credentials[self::PASSWORD]), 'email' => $apiData->email, 'realname' => $apiData->realname, 'url' => $apiData->url, 'signature' => $apiData->signature, 'language' => $apiData->language, 'num_posts' => $apiData->num_posts, 'apiToken' => $apiData->apiToken, 'registered' => $registered->getTimestamp());
     if (!$user) {
         $userData['id'] = $apiData->id;
         $userData['group_id'] = 4;
         $this->db->table('users')->insert($userData);
         $user = $this->db->table('users')->where('username = ?', $credentials[self::USERNAME])->fetch();
     } else {
         $user->update($userData);
     }
     return $this->createIdentity($user);
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:32,代码来源:NetteOrgAuthenticator.php

示例15: render

 public function render()
 {
     $template = $this->template;
     $template->settings = $this->presenter->template->settings;
     if ($this->presenter->template->settings['store:enabled']) {
         $template->orders = $this->database->table("orders")->where("orders_states_id NOT", null)->count();
         $template->carts = $this->database->table("orders")->where("orders_states_id", null)->count();
         $stats = new \App\Model\Store\Statistics($this->database);
         $statsParam = $this->presenter->getParameter('stats');
         if ($statsParam == 'td') {
             $arrTurnover = $stats->getData('d', 'price');
             $template->statsLabel = 'Obraty - denní';
         } elseif ($statsParam == 'am') {
             $arrTurnover = $stats->getData('m', 'amount');
             $this->presenter->template->statsLabel = 'Počty objednávek - měsíční';
         } elseif ($statsParam == 'ad') {
             $arrTurnover = $stats->getData('d', 'amount');
             $template->statsLabel = 'Počty objednávek - denní';
         } else {
             $arrTurnover = $stats->getData('m', 'price');
             $template->statsLabel = 'Obraty - denní';
         }
         $template->turnoverDays = $stats->convertKeysToString($arrTurnover);
         if (is_array($arrTurnover)) {
             $template->turnoverValues = implode(",", $arrTurnover);
         }
         $template->setFile(__DIR__ . '/DashboardControl.latte');
         $template->render();
     }
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:30,代码来源:DashboardControl.php


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