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


PHP dibi::fetchSingle方法代码示例

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


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

示例1: translate

 /**
  * Translates the given string.
  * @param  string	translation string
  * @param  int		count (positive number)
  * @return string
  */
 public function translate($message, $count = 1)
 {
     $message = (string) $message;
     //		if (!empty($message) && isset($this->dictionary[$message])) {
     //			$word = $this->dictionary[$message];
     //			if ($count === NULL) $count = 1;
     //
     //			$s = preg_replace('/([a-z]+)/', '$$1', "n=$count;" . $this->meta['Plural-Forms']);
     //			eval($s);
     //			$message = $word->translate($plural);
     //		}
     if (!isset($this->translate[$message]) or $this->translate[$message] == '') {
         $message = $message;
         //			echo $message;exit;
         if (!dibi::fetchSingle("SELECT 1 FROM [lang_translate] WHERE [key] LIKE %s", $message, "AND [id_lang] = %i", $this->id_lang)) {
             //				echo dibi::$sql;
             Lang::insertTranslateKey($message, $this->id_lang);
         }
         $this->translate[$message] = $message;
         Lang::invalidateCache();
     } else {
         $message = $this->translate[$message];
     }
     //
     //		$args = func_get_args();
     //		if (count($args) > 1) {
     //			array_shift($args);
     //			$message = vsprintf($message, $args);
     //		}
     //
     //
     return $message;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:39,代码来源:LangTranslateModel.php

示例2: search_list

function search_list($get)
{
    $out .= '<h1>Search query history</h1>';
    if (empty($get['page'])) {
        $get['page'] = 1;
    }
    $lmt = 10;
    //number of rows per page
    $ofs = $lmt * ($get['page'] - 1);
    $count = dibi::fetchSingle('SELECT count(*) FROM search_history');
    $pagecount = ceil($count / $lmt);
    $searches = dibi::query('SELECT * FROM search_history WHERE f_deleted=0 ORDER BY time DESC %lmt %ofs', $lmt, $ofs);
    for ($i = 1; $i <= $pagecount; $i++) {
        $out .= '<a href="index.php?action=searchlist&page=' . $i . '">' . $i . '</a>&nbsp; ';
    }
    $out .= '<table>';
    foreach ($searches as $search) {
        $out .= '<tr>';
        $out .= '<td>' . $search['time'] . '</td>';
        $out .= '<td>' . $search['ip'] . '</td>';
        $out .= '<td>' . $search['query'] . '</td>';
        $out .= '</tr>';
    }
    $out .= '</table>';
    return $out;
}
开发者ID:etnetera-candidate,项目名称:gitlist,代码行数:26,代码来源:index.php

示例3: match

 /**
  * Maps HTTP request to a PresenterRequest object.
  * @param  Nette\Web\IHttpRequest
  * @return PresenterRequest|NULL
  */
 public function match(IHttpRequest $context)
 {
     if (!preg_match('#^/([a-z0-9]{1,3})/(.*?)/?$#', $context->getUri()->path, $matches)) {
         return NULL;
     }
     $lang = $matches[1];
     $categories = $matches[2];
     $pom = explode("/", $categories);
     $last = end($pom);
     if (dibi::fetchSingle("\n\t\t\tSELECT\n\t\t\t    COUNT(*)\n\t\t\tFROM\n\t\t\t    category\n\t\t\t    JOIN category_lang USING(id_category)\n\t\t\t    JOIN [lang] USING(id_lang)\n\t\t\tWHERE iso=%s", $lang, "AND link_rewrite = %s", $last)) {
         $presenter = 'Front:Eshop';
     } elseif (dibi::fetchSingle("SELECT COUNT(*) FROM menu_item WHERE lang = %s", $lang, "AND url_identifier=%s", $last)) {
         $presenter = 'Front:List';
     } else {
         return NULL;
     }
     // alternativa: použít jednu tabulku s páry URL -> jméno Presenteru
     // výhoda: jeden lookup místo (až) tří, neměřitelně vyšší rychlost ;)
     // nevýhoda: nutnost ji udržovat :-(
     // alternativa č.2: místo COUNT(*) načíst z DB celý záznam a předat v parametru presenteru
     // výhoda: stejně jej bude potřebovat
     // nevýhoda: nadstandardní závislost mezi routerem a presenterem
     $params = $context->getQuery();
     //                $params['link_rewrite'] = $last;
     $params['lang'] = $lang;
     return new NPresenterRequest($presenter, $context->getMethod(), $params, $context->getPost(), $context->getFiles(), array('secured' => $context->isSecured()));
 }
开发者ID:oaki,项目名称:demoshop,代码行数:32,代码来源:ShopRoute_old.php

示例4: saveArticle

 function saveArticle($values, $id_node)
 {
     $tmp = dibi::fetch("SELECT * FROM article WHERE id_node=%i", $id_node);
     unset($values['id_node']);
     //odstranenie premennych ktore niesu v databaze
     $values = Tools::getValuesForTable('article', $values);
     $name = NStrings::webalize($values['url_identifier']);
     $newname = "";
     $i = 0;
     while ($i < 50) {
         if ($i == 0) {
             $newname = $name;
         } else {
             $newname = NStrings::webalize($name . $i);
         }
         $s = dibi::fetchSingle("SELECT COUNT(id_node) FROM article WHERE url_identifier=%s", $newname, " AND id_node!=%i", $id_node);
         if ($s == 0) {
             break;
         } else {
             $i++;
         }
     }
     $values['url_identifier'] = $newname;
     dibi::query("UPDATE article SET ", $values, " WHERE id_node=%i", $id_node);
     NEnvironment::getService('Article')->invalidateCache();
 }
开发者ID:oaki,项目名称:demoshop,代码行数:26,代码来源:article.php

示例5: addAnswer

 public static function addAnswer($values)
 {
     $id_poll = $values['id_poll'];
     $sequence = dibi::fetchSingle("SELECT MAX(sequence)+1 FROM  poll_answer WHERE id_poll=%i", $id_poll);
     $values['sequence'] = $sequence;
     dibi::query("INSERT INTO poll_answer ", $values);
 }
开发者ID:oaki,项目名称:demoshop,代码行数:7,代码来源:PollModel.php

示例6: saveProduct

 function saveProduct($values, $id_node)
 {
     $collums = Tools::getCollum('module_product');
     foreach ($values as $k => $v) {
         if (!in_array($k, $collums)) {
             unset($values[$k]);
         }
     }
     $newname = "";
     $name = $values['title'];
     $i = 0;
     while ($i < 50) {
         if ($i == 0) {
             $newname = $name;
         } else {
             $newname = NStrings::webalize($name . $i);
         }
         $s = dibi::fetchSingle("SELECT COUNT(id_node) FROM [module_product] WHERE url_identifier=%s", $newname, " AND id_node!=%i", $id_node);
         if ($s == 0) {
             break;
         } else {
             $i++;
         }
     }
     $values['url_identifier'] = $newname;
     dibi::query("UPDATE [module_product] SET ", $values, " WHERE id_node=%i", $id_node);
     Log::addLog($this, "Uprava produktu", "Menil:" . NEnvironment::getSession('Authentication')->login_form, $values['title'], $id_node);
 }
开发者ID:oaki,项目名称:demoshop,代码行数:28,代码来源:Admin_Product.php

示例7: match

 /**
  * Maps HTTP request to a PresenterRequest object.
  * @param  Nette\Web\IHttpRequest
  * @return PresenterRequest|NULL
  */
 public function match(IHttpRequest $context)
 {
     \Nette\Diagnostics\FireLogger::log('-------------');
     \Nette\Diagnostics\FireLogger::log($context);
     return NULL;
     if (!preg_match('#^/([a-zA-Z0-9-]+)/?$#', $context->getUri()->path, $matches)) {
         return NULL;
     }
     $id = $matches[1];
     if (dibi::fetchSingle("SELECT COUNT(*) FROM tabulka_produktu WHERE nameid=%s", $id)) {
         $presenter = 'Front:Product';
     } elseif (dibi::fetchSingle("SELECT COUNT(*) FROM tabulka_kategorie WHERE nameid=%s", $id)) {
         $presenter = 'Front:Category';
     } elseif (dibi::fetchSingle("SELECT COUNT(*) FROM tabulka_s_clanky WHERE nameid=%s", $id)) {
         $presenter = 'Front:Article';
     } else {
         return NULL;
     }
     // alternativa: použít jednu tabulku s páry URL -> jméno Presenteru
     // výhoda: jeden lookup místo (až) tří, neměřitelně vyšší rychlost ;)
     // nevýhoda: nutnost ji udržovat :-(
     // alternativa č.2: místo COUNT(*) načíst z DB celý záznam a předat v parametru presenteru
     // výhoda: stejně jej bude potřebovat
     // nevýhoda: nadstandardní závislost mezi routerem a presenterem
     $params = $context->getQuery();
     $params['id'] = $id;
     return new PresenterRequest($presenter, $context->getMethod(), $params, $context->getPost(), $context->getFiles(), array('secured' => $context->isSecured()));
 }
开发者ID:pemasat,项目名称:nixla,代码行数:33,代码来源:TestRoute.php

示例8: actionGenerateExcel

 function actionGenerateExcel($id_order)
 {
     $order = OrderModel::get($id_order);
     //print_r($order);exit;
     $order['country_name'] = dibi::fetchSingle("SELECT country_name FROM [gui_user_country] WHERE iso = %s", $order['iso']);
     $date = new DateTime($order['add_date']);
     $order['create_date'] = $date->format('d/m/Y');
     require_once LIBS_DIR . '/PHPExcel/PHPExcel.php';
     //cesta k sablone
     $dir = WWW_DIR . "/uploaded/order_excel_template/invoice_template.xlsx";
     $objPHPExcel = PHPExcel_IOFactory::load($dir);
     // Set active sheet
     $objPHPExcel->setActiveSheetIndex(0);
     // Assign data
     $invoice_number = str_pad($order['id_order'], 5, "0", STR_PAD_LEFT);
     //		var_dump($invoice_number);exit;
     $objPHPExcel->getActiveSheet()->setCellValue('INVOICE_NUMBER', $invoice_number);
     $objPHPExcel->getActiveSheet()->setCellValue('VARIABLE_SYMBOL', $invoice_number);
     $objPHPExcel->getActiveSheet()->setCellValue('B_NAME', $order['name'] . ' ' . $order['surname'] . ' ' . $order['company_name']);
     $objPHPExcel->getActiveSheet()->setCellValue('B_STREET', $order['address']);
     $objPHPExcel->getActiveSheet()->setCellValue('B_CITY', $order['city']);
     $objPHPExcel->getActiveSheet()->setCellValue('B_COUNTRY', $order['country_name']);
     if ($order['ico'] != '') {
         $objPHPExcel->getActiveSheet()->setCellValue('B_ICO', $order['ico']);
         $objPHPExcel->getActiveSheet()->setCellValue('B_TITLE_ICO', 'IČO:');
     }
     if ($order['dic'] != '') {
         $objPHPExcel->getActiveSheet()->setCellValue('B_IC_DPH', $order['dic']);
         $objPHPExcel->getActiveSheet()->setCellValue('B_TITLE_IC_DPH', 'IČO:');
     }
     $objPHPExcel->getActiveSheet()->setCellValue('B_IC_DPH', $order['dic']);
     $objPHPExcel->getActiveSheet()->setCellValue('CREATE_DATE', $order['create_date']);
     $objPHPExcel->getActiveSheet()->setCellValue('PAYMENTS_METHOD', 'PP');
     $objPHPExcel->getActiveSheet()->setCellValue('DPH_TITLE', 'DPH ' . NEnvironment::getVariable('vat') . "%");
     $objPHPExcel->getActiveSheet()->setCellValue('DPH', NEnvironment::getVariable('vat'));
     // Add data
     $collum = 18;
     $vat_coef = 1 + NEnvironment::getVariable('vat') / 100;
     foreach ($order['products'] as $p) {
         $objPHPExcel->getActiveSheet()->setCellValue('B' . $collum, $p['ean13']);
         $objPHPExcel->getActiveSheet()->setCellValue('C' . $collum, $p['name']);
         $objPHPExcel->getActiveSheet()->setCellValue('D' . $collum, $p['count']);
         //mnozstvo
         $objPHPExcel->getActiveSheet()->setCellValue('E' . $collum, "ks");
         //jed
         $objPHPExcel->getActiveSheet()->setCellValue('F' . $collum, $p['price'] / $vat_coef);
         //bez dph
         $objPHPExcel->getActiveSheet()->setCellValue('G' . $collum, $p['count'] * $p['price'] / $vat_coef);
         ++$collum;
     }
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     // Redirect output to a client’s web browser (Excel2007)
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="faktura_' . $invoice_number . '.xlsx"');
     header('Cache-Control: max-age=0');
     $objWriter->save('php://output');
     exit;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:58,代码来源:Admin_OrderPresenter.php

示例9: beforeRender

 function beforeRender()
 {
     parent::beforeRender();
     $this->template->id_category = $this->id;
     $this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang);
     //ak je iba jeden parent zobraz kategorie, inak zobraz produkty
     if (count($this->template->category_parents) == 1) {
         $id_parent = current($this->template->category_parents);
         $category_list = CategoryModel::getFluent('id_category')->where('id_parent = %i', $id_parent)->fetchAll();
         $this->template->categories = array();
         foreach ($category_list as $l) {
             $_tmp = CategoryModel::get($l->id_category, $this->id_lang);
             $_tmp['product_count'] = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $l->id_category);
             $this->template->categories[] = $_tmp;
         }
         $this->template->product_count = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $this->id);
     } else {
         $list = dibi::select('id_product')->from('product')->join('category_product')->using('(id_product)')->join('product_param')->using('(id_product)')->where('id_category = ', $this->id, 'AND product.active = 1');
         /*
          * Filter
          */
         $orderSession = $this['quickFilter']->getSession();
         //			dde($orderSession['order']);
         //			$orderSession['order'] = 'price';
         if ($orderSession['order']) {
             $list->orderBy($orderSession['order']);
         } else {
             $order_array = $this['quickFilter']->getOrderFilterArray();
             $list->orderBy(key($order_array));
         }
         $list->groupBy('id_product');
         //			dump($order);
         //		print_r($list);
         $count_list = clone $list;
         //			$count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
         $count = count($count_list);
         $vp = new VisualPaginator($this, 'paginator');
         $paginator = $vp->getPaginator();
         $numOnPageSession = $this['quickFilter']->getSession();
         if ($numOnPageSession['num']) {
             $paginator->itemsPerPage = $numOnPageSession['num'];
         } else {
             $num_on_page_array = $this['quickFilter']->getNumOnPageFilterArray();
             $paginator->itemsPerPage = key($num_on_page_array);
         }
         $paginator->itemCount = (int) $count;
         $this->template->product_count = $count;
         $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
         //dump($this->template->products);
         $this->template->paginator = $paginator;
         foreach ($this->template->products as $k => $p) {
             $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user);
         }
         //		};
     }
     //		print_r($this->template->products);exit;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:57,代码来源:Front_EshopPresenter.php

示例10: handleSaveSetting

 function handleSaveSetting(NForm $form)
 {
     $values = $form->getValues();
     //ak je to "obchodne podmienky" zisti id_page a zapis do konfigu
     $values['CONDITIONS_CMS_PAGE_ID'] = dibi::fetchSingle("SELECT id_menu_item FROM [menu_item] JOIN [node] \n\t\t\t\tUSING(id_menu_item) WHERE node.id_node = %i", $values['CONDITIONS_CMS_ID']);
     $setting = $this->getService('Setting');
     foreach ($values as $name => $value) {
         $setting->insert_update($name, array('name' => $name, 'value' => $value));
     }
     $this->flashMessage('Nastavenia boli upravené');
     $this->redirect('this');
 }
开发者ID:oaki,项目名称:demoshop,代码行数:12,代码来源:Admin_Setting_HomepagePresenter.php

示例11: idToSlug

 public function idToSlug($id)
 {
     $key = 'idToSlug' . $id;
     if (!isset($this->cache[$key])) {
         $name = dibi::fetchSingle("SELECT url_identifier FROM [menu_item] WHERE id_menu_item = %i", $id);
         if (!$name) {
             $name = NULL;
         }
         $this->cache[$key] = $name;
     }
     return $this->cache[$key];
 }
开发者ID:oaki,项目名称:demoshop,代码行数:12,代码来源:NodeModel.php

示例12: idToSlug

 public function idToSlug($id)
 {
     $key = 'idToSlug(' . $id . ')';
     //		echo $key;
     //		return $name = dibi::fetchSingle("SELECT url_identifier FROM [article] WHERE id_node = %i",$id);
     $slug = $this->loadCache($key);
     if ($slug) {
         return $slug;
     } else {
         $name = dibi::fetchSingle("SELECT url_identifier FROM [article] WHERE id_node = %i", $id);
         if (!$name) {
             $name = NULL;
         }
     }
     return $this->saveCache($key, $name);
 }
开发者ID:oaki,项目名称:demoshop,代码行数:16,代码来源:ArticleModel.php

示例13: match

    public function match(IHttpRequest $httpRequest)
    {
        //            print_r($httpRequest);
        $request = parent::match($httpRequest);
        if ($request === NULL) {
            return NULL;
        }
        $params = $request->getParams();
        //print_r($params);
        if (dibi::fetchSingle('SELECT
									COUNT(*)
								 FROM
									%n', $this->table, '
                                 WHERE									
									%n = %s', $this->column, $params['categories']) == 0) {
            return NULL;
        }
        return $request;
    }
开发者ID:oaki,项目名称:demoshop,代码行数:19,代码来源:PageRouter_old.php

示例14: save

 /**
  * Saves extracted data into gettext file
  * @param string $outputFile
  * @param array $data
  * @return GettextExtractor
  */
 public function save()
 {
     $e = new MyExtractor();
     $data = $e->getData();
     $id_lang = dibi::fetchSingle("SELECT id_lang FROM [lang] WHERE iso = %s", $this->lang);
     if (!$id_lang) {
         throw new Exception('ISO lang neexistuje');
     }
     foreach ($data as $k => $d) {
         $arr = array('id_lang' => $id_lang, 'key' => $k, 'files' => implode(", ", $d));
         try {
             dibi::query("INSERT INTO lang_translate", $arr);
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
     self::invalidateCache();
     return $this;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:25,代码来源:MyTranslator.php

示例15: action

 function action()
 {
     parent::action();
     if (isset($_GET['ajax_save_promo']) and $_GET['ajax_save_promo'] == 1) {
         $arr = Tools::getValuesForTable('promo_text', $_POST);
         //zisti ci existuje
         $id_file = dibi::fetchSingle("SELECT id_file FROM [promo_text] WHERE id_file = %i", $_POST['id_file']);
         //
         //			$arr = array(
         //				'title'=>$_POST['title'],
         //				'alt'=>$_POST['alt'],
         //				'link'=>$_POST['link'],
         //				'link_name'=>$_POST['link_name'],
         //			);
         if ($id_file) {
             dibi::query("UPDATE promo_text SET ", $arr, "WHERE id_file = %i", $id_file);
         } else {
             $arr['id_file'] = $_POST['id_file'];
             dibi::query("INSERT INTO promo_text ", $arr);
         }
         exit;
     }
 }
开发者ID:oaki,项目名称:demoshop,代码行数:23,代码来源:Admin_Promo.php


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