• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Database\Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: invoke

 public function invoke(Container $container, Context $db)
 {
     $driver = new PostgreSqlNetteDbDriver($db, 'migrations');
     $printer = new Console();
     $runner = new Runner($driver, $printer);
     if ($this->in->getOption('init')) {
         ob_start();
         $runner->run($runner::MODE_INIT);
         $sql = ob_get_clean();
         $db->query($sql);
         $this->out->writeln('<info>Migrations table created</info>');
         return;
     }
     $g = new Group();
     $g->directory = __DIR__ . '/../../../migrations/struct';
     $g->dependencies = [];
     $g->enabled = TRUE;
     $g->name = 'struct';
     $runner->addGroup($g);
     $runner->addExtensionHandler('sql', new Extensions\NetteDbSql($db));
     $runner->addExtensionHandler('php', new PhpClass(['db' => $db], $container));
     try {
         $runner->run();
         return;
     } catch (\PDOException $e) {
         if ($e->getCode() !== '42S02') {
             throw $e;
         }
         // lets hope locale is english
         if (!preg_match("~Table '.*?\\.migrations' doesn't exist~", $e->getMessage())) {
             throw $e;
         }
         $this->out->writeln('<error>Migrations table does not exist, init migrations first</error>');
     }
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:35,代码来源:Migrate.php


示例2: __construct

 public function __construct($tableName, Context $context)
 {
     $this->tableName = $tableName;
     $this->driver = $context->getConnection()->getSupplementalDriver();
     $this->conventions = $context->getConventions();
     $this->structure = $context->getStructure();
     $this->delimitedTable = implode('.', array_map([$this->driver, 'delimite'], explode('.', $tableName)));
 }
开发者ID:ricco24,项目名称:database,代码行数:8,代码来源:SqlBuilder.php


示例3: 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


示例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: addQuestion

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


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->database->query($this->getFile(self::FILE_EMAILS_TABLE));
     $this->database->query($this->getFile(self::FILE_GROUPS_TABLE));
     $this->database->query($this->getFile(self::FILE_SENDER_LIST_TABLE));
     $this->database->query($this->getFile(self::FILE_GROUP_EMAIL_TABLE));
 }
开发者ID:trejjam,项目名称:emailing,代码行数:7,代码来源:CliInstall.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->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


示例14: addTestResult

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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: actionEdit

 public function actionEdit($postId)
 {
     $post = $this->database->table('posts')->get($postId);
     if (!$post) {
         $this->error('Post not found');
     }
     $this['postForm']->setDefaults($post->toArray());
 }
开发者ID:luminousinfoways,项目名称:pccfoas,代码行数:8,代码来源:HomepagePresenter.php


示例20: add

 public function add($id, $quantity = 1, array $options = [])
 {
     $product = $this->database->table('product')->get($id);
     if (!$product) {
         throw new InvalidArgumentException('Product not found.');
     }
     $this->cart->addItem($product->id, $product->price, $quantity, $options)->setName($product->name)->setImage($product->image)->setUnit($product->unit)->setVatRate($product->vat)->setLink('Product:default')->setLinkArgs($product->id);
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:8,代码来源:CartFacade.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Database\Helpers类代码示例发布时间:2022-05-23
下一篇:
PHP Database\Connection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap