本文整理汇总了PHP中dibi::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP dibi::fetch方法的具体用法?PHP dibi::fetch怎么用?PHP dibi::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dibi
的用法示例。
在下文中一共展示了dibi::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderDefault
public function renderDefault()
{
//uvod
$home = dibi::fetch("SELECT * FROM [menu_item] WHERE home = 1 AND lang = %s", $this->lang);
if (!$home) {
$home = dibi::fetch("SELECT * FROM [menu_item] WHERE lang = %s", $this->lang, "ORDER BY sequence LIMIT 1");
}
$this->template->id_menu_item = $home['id_menu_item'];
/*
* META INFO
*/
$this['header']->addTitle($home['meta_title']);
$this['header']->setDescription($home['meta_description']);
$node = $this->getService('Node');
$query = $node->getAll($this->template->id_menu_item);
$this->template->node_list = $query->fetchAll();
//produkty na uvode
$list = dibi::select('id_product')->from('product')->where('home = 1');
$count_list = clone $list;
$count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
$vp = new VisualPaginator($this, 'paginator');
$paginator = $vp->getPaginator();
$paginator->itemsPerPage = 12;
$paginator->itemCount = (int) $count;
$this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
$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);
}
/* widget */
$this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang);
$this['productNewsSaleAvaiableTable']->setUser($this->user);
}
示例2: duplicate
public static function duplicate($id_node, $new_id_node)
{
// nacitanie, co ma skopirovat
$values = dibi::fetch("SELECT * FROM [" . self::TABLE . "] WHERE id_node = %i", $id_node);
//vytvorenie
self::add($new_id_node);
self::saveHome($values, $new_id_node);
}
示例3: get
static function get($id_order, $id_user = null)
{
$order = dibi::fetch("SELECT * FROM [order] WHERE id_order = %i", $id_order, "%if", $id_user != null, "AND id_user = %i", $id_user, "AND deleted = 0 %end");
if (!empty($order)) {
$order['products'] = dibi::fetchAll("SELECT * FROM [order_product] WHERE id_order = %i", $id_order);
}
return $order;
}
示例4: get
function get($id_node)
{
$a = dibi::fetch("SELECT *, DATE_FORMAT(add_date, '%d.%m.%Y') AS add_date_formated FROM [article] WHERE id_node=%i", $id_node);
if (!$a) {
return false;
}
$a['files'] = self::getFiles($id_node);
$a['first_img'] = isset($a['files'][0]) ? $a['files'][0] : array('src' => 'no-image', 'ext' => 'jpg');
return $a;
}
示例5: authenticate
public static function authenticate($login, $password)
{
return \dibi::fetch('
SELECT *
FROM [cv2_user]
WHERE
login = %s', $login, '
AND
password = %s', self::hash($password, $login));
}
示例6: login
public function login($username, $password)
{
//echo $this->return_hash($password);
$user = dibi::fetch("SELECT * FROM user WHERE username=%s AND password=%s", $username, $this->return_hash($password));
if (!$user) {
throw new Exception('Neplatné jméno nebo heslo.');
}
//$_SESSION['user'] = $user;
$_SESSION['user'] = serialize($user);
}
示例7: getFiles
public function getFiles($id_node)
{
$files = FilesNode::getAllFiles('Home', $id_node);
foreach ($files as $k => $l) {
$i = dibi::fetch("SELECT title, link, alt, link_name FROM [promo_text] WHERE id_file = %i", $l['id_file']);
$files[$k]['title'] = $i['title'];
$files[$k]['link'] = $i['link'];
$files[$k]['alt'] = $i['alt'];
$files[$k]['link_name'] = $i['link_name'];
}
return $files;
}
示例8: renderDefault
function renderDefault()
{
$this->template->blog_box = dibi::fetchAll("SELECT * FROM menu_item WHERE parent = %i", dibi::fetch("SELECT * FROM menu_item WHERE url_identifier = 'blog'")->id_menu_item);
foreach ($this->template->blog_box as $box) {
$box['data'] = dibi::fetchAll("\n\t\t\t\tSELECT * FROM node \n\t\t\t\tLEFT JOIN article USING (id_node)\n\t\t\t\tWHERE \n\t\t\t\tid_menu_item = %i", $box->id_menu_item, "\n\t\t\t\tGROUP BY id_node\n\t\t\t\tORDER BY id_node DESC\n\t\t\t\tLIMIT 0, 5\n\t\t\t");
foreach ($box['data'] as $article) {
$article['url'] = $this->getPresenter()->link('Blog:current', array('categories' => $box->url_identifier, 'url_identifier' => $article->url_identifier));
if ($image = FilesNode::getOneFirstFile('article', $article->id_node)) {
$article['image_url'] = Files::gURL($image->src, $image->ext, 220, 160, 6);
}
}
}
}
示例9: authenticate
/**
* Performs an authentication
* @param array
* @return Nette\Security\Identity
* @throws AuthenticationException
*/
public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
$row = dibi::fetch('SELECT * FROM users WHERE login=%s', $username);
if (!$row) {
throw new AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
}
if ($row->password !== $this->calculateHash($password)) {
throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
}
unset($row->password);
return new Nette\Security\Identity($row->id, $row->role, $row);
}
示例10: authenticate
/**
* Performs an authentication
* @param array
* @return IIdentity
* @throws AuthenticationException
*/
public function authenticate(array $credentials)
{
$username = $credentials[self::USERNAME];
$password = md5($credentials[self::PASSWORD]);
$row = dibi::fetch('SELECT * FROM users WHERE login=%s', $username);
if (!$row) {
throw new AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
}
if ($row->password !== $password) {
throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
}
unset($row->password);
return new Nette\Security\Identity($row->id, $row->role, $row);
}
示例11: attached
protected function attached($presenter)
{
parent::attached($presenter);
if (!$this->isSubmitted()) {
$row = dibi::fetch("SELECT * FROM users WHERE username = %s", $presenter->user->id);
$row['tags'] = $row['tags'];
$row['projects'] = array_map(function ($a) {
return trim($a, '()');
}, explode(",", $row['projects']));
if ($row) {
$this->setValues($row);
}
}
}
示例12: render
function render($id_poll = NULL)
{
if ($id_poll == NULL) {
$id_poll = $this->id_poll;
}
$template = $this->template;
$template->setFile(dirname(__FILE__) . '/poll.phtml');
$template->l = dibi::fetch("SELECT * FROM poll WHERE id_poll=%i", $id_poll, " AND from_date <= CURRENT_DATE() AND to_date >= CURRENT_DATE()");
$template->answer = dibi::fetchAll("SELECT *, (SELECT COUNT(id_poll_ip_vol) FROM poll_ip_vol WHERE id_poll_answer = poll_answer.id_poll_answer) AS c FROM poll_answer WHERE id_poll=%i", $id_poll, "ORDER BY sequence");
$template->answer_count = 0;
//spocita iba tie co uz maju vysledok
foreach ($template->answer as $a) {
$template->answer_count += $a['c'];
}
$template->render();
}
示例13: add
function add($values)
{
$arr = array('name' => $values['name'], 'text' => $values['text'], 'id_node' => $values['id_node'], 'addDate' => new DateTime(), 'status' => 1, 'comment_parent' => (isset($values['comment_parent']) and $values['comment_parent'] != '') ? $values['comment_parent'] : NULL);
dibi::query("INSERT INTO [comment] ", $arr);
$l = dibi::fetch("\n\t\t\tSELECT \n\t\t\t\tmenu_item.url_identifier AS menu_url_identifier,\n\t\t\t\tarticle.url_identifier\n\t\t\tFROM \n\t\t\t\t[node]\n\t\t\t\tJOIN [menu_item] USING(id_menu_item)\n\t\t\t\tJOIN article USING(id_node)\n\t\t\tWHERE \n\t\t\t\tnode.id_node = %i", $values['id_node'], "\n\t\t");
$template = $this->template;
$template->setFile(dirname(__FILE__) . '/CommentEmailNotification.phtml');
$template->values = $l;
$uri = NEnvironment::getHttpRequest()->getUri();
$template->url = $uri->scheme . '://' . $uri->host . $this->getPresenter()->link(":Homepage:article", $l['menu_url_identifier'], $l['url_identifier']);
// $mail = new MyMail();
// $mail->addTo( 'info@sprievodcaockovanim.sk' );
// $mail->addBcc('form@q7.sk');
//
// $mail->setSubject('Sprievodca ockovanim - Nový komentár.');
// if(NEnvironment::isProduction())
// $mail->send($template);
}
示例14: render
public function render()
{
$template = new NFileTemplate();
$template->registerFilter(new NLatteFilter());
$template->setFile(dirname(__FILE__) . '/promo.phtml');
$template->id = 'Multiupload_' . $this->type_module;
// $template->css = file_get_contents(dirname(__FILE__).'/fileuploader.css');
// $template->js = file_get_contents(dirname(__FILE__).'/fileuploader.js');
if (_NETTE_MODE) {
$template->action = NEnvironment::getApplication()->getPresenter()->link('Homepage:upload');
} else {
$template->action = '/admin.php';
}
$template->parsed_url = $this->parsed_url;
$template->list = self::getAllFiles($this->type_module, $this->id_module, $this->type);
foreach ($template->list as $k => $l) {
$i = dibi::fetch("SELECT title, link, alt, link_name FROM [promo_text] WHERE id_file = %i", $l['id_file']);
$template->list[$k]['title'] = $i['title'];
$template->list[$k]['link'] = $i['link'];
$template->list[$k]['alt'] = $i['alt'];
$template->list[$k]['link_name'] = $i['link_name'];
}
return $template;
}
示例15: createComponent
function createComponent($name)
{
switch ($name) {
// case 'addForm':
// $form = $this->baseForm();
// $form->addSubmit('btn', 'Pridať');
//// $values['product_alternative'] = ProductModel::getFluent($this->id_lang)->where('id_category = 5')->fetchPairs("id_product",'id_product');
// //poziadavka klienta - zobrat vsetky produkty z doplnkov
//
//
// $form->setDefaults( array('id_product_template_group'=>$this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate()) );
//
//
// $form->onSuccess[] = callback($this, 'add');
// return $form;
// break;
case 'editForm':
$id_product = $this->getPresenter()->getParam('id');
$form = $this->baseForm();
$form['id_product']->setValue($id_product);
$values = array();
//Titulok - doplnit categoria+ nazov produktu
//Kľúčové slová -
//Meta popis - doplnit categoria+ nazov produktu + Výkon + Dĺžka Horenia
foreach ($this->template->langs as $l) {
$val = ProductModel::get($id_product, $l['id_lang']);
// ziste ktore komponenty maju jazykovu mutaciu
$controls_for_lang = array();
foreach ($form->getComponents() as $control) {
if (strpos($control->getName(), CategoryFormControl::$_separator)) {
if (strpos($control->getName(), CategoryFormControl::$_separator . $l['iso'])) {
list($val_key) = explode(CategoryFormControl::$_separator . $l['iso'], $control->getName());
$values += array($control->getName() => $val[$val_key]);
}
} else {
if (isset($val[$control->getName()])) {
$values += array($control->getName() => $val[$control->getName()]);
}
}
}
}
//print_r(ProductModel::getProductAlternative($id_product));exit;
$values['product_alternative'] = ProductModel::getProductAlternative($id_product);
// vyriesenie categorii
//nacitanie prveho parametru - iba pre jednoparametrove produkty
$param = (array) dibi::fetch("SELECT * FROM [product_param] WHERE id_product = %i", $id_product);
$form->setDefaults(array_merge($param, $values));
$form->addSubmit('btn_save_and_stay', 'Upraviť a zostať tu');
$form->addSubmit('btn_save', 'Upraviť');
$form->onSuccess[] = callback($this, 'save');
return $form;
break;
/*
* generator
*/
/*
* generator
*/
case 'generatorForm':
//ProductModel::repairMinPrice();
NFormContainer::extensionMethod('NFormContainer::addCheckboxList', array('CheckboxList', 'addCheckboxList'));
$sizes = dibi::query("SELECT size FROM [product_param] WHERE size !='' GROUP BY size")->fetchPairs('size', 'size');
$colors = dibi::query("SELECT color FROM [product_param] WHERE color !='' GROUP BY color")->fetchPairs('color', 'color');
$materials = dibi::query("SELECT material FROM [product_param] WHERE material !='' GROUP BY material")->fetchPairs('material', 'material');
$f = new MyForm();
// $f->getElementPrototype()->addClass('ajax');
$renderer = $f->getRenderer();
$renderer->wrappers['controls']['container'] = NHtml::el('div')->addClass('container');
$renderer->wrappers['pair']['container'] = NHtml::el('div')->addClass('pair-container');
$renderer->wrappers['label']['container'] = NHtml::el('h3');
$renderer->wrappers['control']['container'] = NHtml::el('div')->addClass('input-container');
// usort($sizes, 'EshopProductControl::cmp');
$f->addCheckboxList('size', 'Veľkosť', $sizes);
$f->addCheckboxList('color', 'Farba', $colors);
$f->addCheckboxList('material', 'Material', $materials);
//ak je pridavanie a neexistuje id
$f->addHidden('id_product', $this->getParam('id'));
//
//
// $renderer = $f->getRenderer();
// $renderer->wrappers['label']['container'] = NULL;
//
// //ziskaj vsetky mozne velkosti
// $sizes = dibi::fetchAll("SELECT size FROM [product_param] GROUP BY size");
// $f->addGroup('Veľkosť');
// foreach($sizes as $k=>$size){
// $f->addCheckbox('size_'.$k, $size['size']);
// }
//
// //ziskaj vsetky mozne farby
// $colors = dibi::fetchAll("SELECT color FROM [product_param] GROUP BY color");
// $f->addGroup('Farba');
// foreach($colors as $k=>$color){
// $f->addCheckbox('color_'.$k, $color['color']);
// }
//
// //ziskaj vsetky mozne material
// $materials = dibi::fetchAll("SELECT material FROM [product_param] GROUP BY material");
// $f->addGroup('Material');
// foreach($materials as $k=>$material){
//.........这里部分代码省略.........