本文整理匯總了PHP中dibi::fetchAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::fetchAll方法的具體用法?PHP dibi::fetchAll怎麽用?PHP dibi::fetchAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::fetchAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
function __construct()
{
//-----vytvorenie objektu menu
$menu = new MenuItem();
$menu->menuAction();
//-----vytvorenie objektu node
$node = new node();
$node->nodeAction();
MT::addContent($menu->render(), 'leftHolder');
try {
if (isset($_GET['id_menu_item']) or isset($_GET['addMenuItem']) or isset($_GET['changeMenuItem'])) {
MT::addTemplate(APP_DIR . '/templates/admin/modulHolder.phtml', 'modulHolder');
MT::addVar('modulHolder', 'type_modul', dibi::fetchAll("SELECT * FROM [type_modul] WHERE visible_for_user='1'"));
}
//zobrazenie zmeny polozky pre menu
if (isset($_GET['changeMenuItem'])) {
$menu->showChangeMenuItem($_GET['id_menu_item']);
}
if (isset($_GET['id_menu_item']) and !isset($_GET['changeMenuItem'])) {
$node->showModul();
}
//pridanie polozky do menu
if (isset($_GET['addMenuItem'])) {
$menu->showAddMenuItem();
}
//zachytenie vynimie
} catch (NodeException $e) {
echo '<div style="border: 2px solid red; padding: 5px;">' . $e->getMessage() . '</div>';
exit;
}
}
示例2: createComponentAddEdit
protected function createComponentAddEdit($name)
{
$form = new NAppForm($this, $name);
$access = array(1 => 'Allow', 0 => 'Deny');
// roles
$mroles = new RolesModel();
$roles = $mroles->getTreeValues();
// resources
$resources[0] = '- All resources -';
$mresources = new ResourcesModel();
$rows = $mresources->getTreeValues();
foreach ($rows as $key => $row) {
// function array_merge does't work correctly with integer indexes
// manual array merge
$resources[$key] = $row;
}
// privileges
$privileges[0] = '- All privileges -';
$rows = dibi::fetchAll('SELECT id, name FROM [gui_acl_privileges] ORDER BY name;');
foreach ($rows as $row) {
// function array_merge does't work correctly with integer indexes
// manual array merge
$privileges[$row->id] = $row->name;
}
//$renderer = $form->getRenderer();
//$renderer->wrappers['label']['suffix'] = ':';
//$form->addGroup('Add');
$form->addMultiSelect('role_id', 'Role', $roles, 15)->addRule(NForm::FILLED, 'You have to fill roles.');
$form->addMultiSelect('resource_id', 'Resources', $resources, 15)->addRule(NForm::FILLED, 'You have to fill resources.');
$form->addMultiSelect('privilege_id', 'Privileges', $privileges, 15)->addRule(NForm::FILLED, 'You have to fill privileges.');
//$form->addSelect('access', 'Access', $access)
$form->addRadioList('access', 'Access', $access)->addRule(NForm::FILLED, 'You have to fill access.');
$form->addSubmit('assign', 'Assign');
$form->onSuccess[] = array($this, 'addEditOnFormSubmitted');
}
示例3: renderXml
function renderXml()
{
//$this->id_lang
$list = dibi::fetchAll('
SELECT
product.id_product
FROM
`product`
JOIN category_product USING (id_product)
JOIN category USING (id_category)
WHERE
product.active = 1 AND
product.added = 1 AND
category.active = 1
GROUP BY (id_product)');
$this->template->baseUri = 'http://' . $_SERVER['HTTP_HOST'];
$this->id_lang = 1;
$this->template->items = array();
foreach ($list as $k => $l) {
$this->template->items[$k] = ProductModel::getProductWithParams($l['id_product'], $this->id_lang, NULL);
$this->template->items[$k]['url'] = $this->link(':Front:Product:default', array('id' => $l['id_product'], 'id_category' => $this->template->items[$k]['main_category']));
//zisti nazvy kategorii
$category = array();
foreach ($this->template->items[$k]['categories'] as $cat) {
$tmp = CategoryModel::get($cat['id_category'], $this->id_lang);
$category[] = $tmp['name'];
}
$this->template->items[$k]['categories_name'] = implode(" | ", $category);
}
// dde($this->template->items);
}
示例4: 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;
}
示例5: add_reviewer
public function add_reviewer($id_article, $id_user)
{
$res = dibi::fetchAll("SELECT article_id_article,user_id_user FROM review" . " WHERE user_id_user =%s" . " AND article_id_article = %s", $id_user, $id_article);
if ($res) {
return false;
} else {
$array = array('article_id_article' => $id_article, 'user_id_user' => $id_user);
dibi::query('INSERT INTO review', $array);
return true;
}
}
示例6: renderList
function renderList($categories)
{
$this->template->blog_box = dibi::fetchAll("SELECT * FROM `menu_item` \nLEFT JOIN node USING (id_menu_item)\nLEFT JOIN article USING (id_node)\nWHERE \nmenu_item.url_identifier = %s", $categories, "\nORDER BY id_node DESC\n");
foreach ($this->template->blog_box as $article) {
$article['url'] = $this->getPresenter()->link('Blog:current', array('categories' => $categories, '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);
}
}
$session = NEnvironment::getSession("Front_List");
$session['back_url'] = $_SERVER['REQUEST_URI'];
}
示例7: findBests
static function findBests()
{
try {
return dibi::fetchAll("SELECT * FROM [article] WHERE [best]");
} catch (DibiDriverException $e) {
// tady dalsi zjistovani, zda se jedna o kritickou chybu
// switch ($e->getCode())
if (11 == $e->getCode()) {
// tabulka je poskozena (zde se jedna o poskozeny soubor, melo by to normalne shodit cely web, ale neudelam tak)
return array();
} else {
throw $e;
}
}
// samotnou DibiException necham vybublat
}
示例8: 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();
}
示例9: handleChangePrice
function handleChangePrice(NFORM $form)
{
$values = $form->getValues();
$id_category = $this->getParam('id_category');
$coeficient = $values['coeficient'];
if (!is_numeric($id_category)) {
$form->addError('Nie je vybraná kategória');
return $form;
}
if ($coeficient == 0) {
$form->addError('Koeficient nesmie byť nula.');
return $form;
}
$list = dibi::fetchAll("\n\t\t\t\tSELECT\n\t\t\t\tproduct_param.id_product_param,\n\t\t\t\tproduct_param.price\n\t\t\t\tFROM\n\t\t\t\t\t[category_product]\n\t\t\t\t\tJOIN [product_param] USING(id_product)\n\t\t\t\tWHERE\n\t\t\t\t\tid_category = %i", $id_category);
foreach ($list as $l) {
$arr = array('price' => round($l['price'] * $coeficient));
dibi::query("UPDATE [product_param] SET ", $arr, "WHERE id_product_param = %i", $l['id_product_param']);
}
}
示例10: __construct
/**
* @param array Array of roles
*/
public function __construct($roles)
{
$resources = dibi::fetchAll('SELECT key_name, name FROM [' . TABLE_RESOURCES . '] ORDER BY name;');
$privileges = dibi::fetchAll('SELECT key_name, name FROM [' . TABLE_PRIVILEGES . '] ORDER BY name;');
$acl = new Acl();
$i = 0;
foreach ($resources as $res) {
foreach ($privileges as $pri) {
foreach ($roles as $role) {
if ($acl->isAllowed($role->key_name, $res->key_name, $pri->key_name)) {
$this->access[$i]['resource'] = $res->name;
$this->access[$i]['privileg'] = $pri->name;
$i++;
break 1;
}
}
}
}
}
示例11: __construct
/**
* @param array Array of roles
*/
public function __construct($roles)
{
$resources = dibi::fetchAll('SELECT key_name, name FROM [' . self::ACL_RESOURCES_TABLE . '] ORDER BY name;');
$privileges = dibi::fetchAll('SELECT key_name, name FROM [' . self::ACL_PRIVILEGES_TABLE . '] ORDER BY name;');
$acl = new Acl();
$i = 0;
foreach ($resources as $res) {
foreach ($privileges as $pri) {
foreach ($roles as $role) {
if (@$acl->isAllowed($role->key_name, $res->key_name, $pri->key_name)) {
// @ to repress NOTICE if assertion required and resource property (id, owner_id, ...) not set yet
$this->access[$i]['resource'] = $res->name;
$this->access[$i]['privileg'] = $pri->name;
$i++;
break 1;
}
}
}
}
}
示例12: changeOrderNode
function changeOrderNode()
{
$order = 'DESC';
if (isset($_GET['modul_id_up'])) {
$id_node = $_GET['modul_id_up'];
}
if (isset($_GET['modul_id_down'])) {
$id_node = $_GET['modul_id_down'];
}
$pom = dibi::fetch("SELECT sequence,id_node,id_menu_item FROM node WHERE id_node=%i", $id_node, " LIMIT 1 ");
if (isset($_GET['modul_id_up'])) {
$sequence = $pom['sequence'] + 1.5;
}
if (isset($_GET['modul_id_down'])) {
$sequence = $pom['sequence'] - 1.5;
}
// print_r($pom);
dibi::query("UPDATE node SET sequence=%s", $sequence, "WHERE id_node=%i", $id_node);
// echo dibi::$sql;
//oprava poradia
$list = dibi::fetchAll("SELECT * FROM node WHERE id_menu_item='" . $pom['id_menu_item'] . "' ORDER BY sequence");
$sequence = 0;
// echo dibi::$sql;
// print_r($list);
// exit;
// exit;
foreach ($list as $l) {
++$sequence;
dibi::query("UPDATE node SET sequence=%i", $sequence, " WHERE id_node=%i", $l['id_node']);
}
// exit;
}
示例13: beforeRender
function beforeRender()
{
//self::parseSparksCSV();
// ProductModel::repairSequenceProductParam();exit;
$cache = NEnvironment::getCache('parse_xml');
$this->all_product_param_db = dibi::query("SELECT code,id_product FROM [product_param]")->fetchPairs('code', 'id_product');
$this->all_product_db = dibi::query("SELECT group_code,id_product FROM [product]")->fetchPairs('group_code', 'id_product');
$this->all_categories_db = dibi::fetchAll("SELECT id_category,name,id_parent FROM [category] JOIN [category_lang] USING(id_category) WHERE id_lang = 1");
// print_r($this->all_categories_db);
//zisti levely
$category_1 = array();
$category_2 = array();
$category_3 = array();
foreach ($this->all_categories_db as $k => $c) {
//prvy
if ($c['id_parent'] == NULL) {
$this->all_categories_db[$k]['level'] = 0;
$category_1[$c['id_category']] = $c['name'];
}
}
foreach ($this->all_categories_db as $k => $c) {
//prvy
if ($c['id_parent'] != NULL) {
foreach ($this->all_categories_db as $k1 => $c1) {
if ($c1['id_category'] == $c['id_parent']) {
if ($this->all_categories_db[$k1]['level'] == 0) {
$this->all_categories_db[$k]['level'] = 1;
$category_2[$c['id_category']] = $c['name'];
}
}
}
}
}
foreach ($this->all_categories_db as $k => $c) {
if (!isset($c['level'])) {
$this->all_categories_db[$k]['level'] = 2;
$category_3[$c['id_category']] = $c['name'];
}
}
$this->category_1 = $category_1;
$this->category_2 = $category_2;
$this->category_3 = $category_3;
// stiahni a rozzipuj subor
// $link
$zip_file_name = WWW_DIR . "/uploaded/xml/xml.zip";
if (isset($cache['xml_file_name'])) {
$xml_file = $cache['xml_file_name'];
} else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.sparks.sk/product/xml/SparksProducts.zip');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$zip = curl_exec($ch);
curl_close($ch);
$fp = fopen($zip_file_name, "w");
fwrite($fp, $zip);
fclose($fp);
$archive = new PclZip($zip_file_name);
$list = $archive->extract(WWW_DIR . '/uploaded/xml/');
if ($list[0]['status'] != 'ok') {
throw new Exception('Nastala chyba pri rozbalovani suboru: ' . $list[0]['stored_filename']);
}
$cache->save('xml_file_name', $list[0]['stored_filename'], array('expire' => time() + 60 * 1));
$xml_file = $list[0]['stored_filename'];
}
$myXMLString = file_get_contents(WWW_DIR . '/uploaded/xml/' . $xml_file);
$myXMLString = iconv('UTF-8', 'windows-1250', $myXMLString);
$doc = new DOMDocument('1.0', 'windows-1250');
$doc->loadXML($myXMLString);
$x = $doc->documentElement;
$c = 0;
foreach ($x->childNodes as $item) {
$product = array();
foreach ($item->childNodes as $i) {
$node_value = preg_replace('#!\\[CDATA\\[#', '', $i->nodeValue);
$node_value = preg_replace('#\\]\\]#', '', $node_value);
// $product[$i->nodeName] = iconv("UTF-8",'ISO-8859-2', $node_value);;
$product[$i->nodeName] = $node_value;
}
//if($c>4000)print_r($product);
$this->add($product);
if (++$c > 5000) {
throw new Exception('prekroceni limit na import poloziek');
}
}
//oprav category rewrite link
CategoryModel::repairCategoryRewriteLink();
}
示例14: getAll
public static function getAll($id_node)
{
return dibi::fetchAll("\n\t\t\tSELECT * \n\t\t\tFROM \n\t\t\t\tgallery \n\t\t\t\tLEFT JOIN gallery_image USING(id_node) \n\t\t\tWHERE \n\t\t\t\tgallery.id_node=%i", $id_node, "\t\t\t\t\n\t\t\tORDER BY sequence\n\t\t");
}
示例15: dump
2 | Table
3 | Computer
*/
// fetch a single row
echo "<h2>fetch()</h2>\n";
$row = dibi::fetch('SELECT title FROM products');
dump($row);
// Chair
// fetch a single value
echo "<h2>fetchSingle()</h2>\n";
$value = dibi::fetchSingle('SELECT title FROM products');
dump($value);
// Chair
// fetch complete result set
echo "<h2>fetchAll()</h2>\n";
$all = dibi::fetchAll('SELECT * FROM products');
dump($all);
// fetch complete result set like association array
echo "<h2>fetchAssoc('title')</h2>\n";
$res = dibi::query('SELECT * FROM products');
$assoc = $res->fetchAssoc('title');
// key
dump($assoc);
// fetch complete result set like pairs key => value
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
$pairs = $res->fetchPairs('product_id', 'title');
dump($pairs);
// fetch row by row
echo "<h2>using foreach</h2>\n";
foreach ($res as $n => $row) {
dump($row);