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


PHP dibi::getConnection方法代码示例

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


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

示例1: __construct

 public function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->db = dibi::getConnection();
     self::$count++;
     //		$this->setWebloaderPaths();
 }
开发者ID:radypala,项目名称:maga-website,代码行数:7,代码来源:BaseControl.php

示例2: createComponentDataGrid

 /**
  * Component factory.
  * @see Nette/ComponentContainer#createComponent()
  */
 protected function createComponentDataGrid($name)
 {
     $grid = new DataGrid();
     $grid->bindDataTable(dibi::getConnection()->dataSource('SELECT
       authorId as id,
       name,
       surname,
       class,', Model::sqlClassName(Model::getSchoolYear()) . 'as classMark,
       (SELECT COUNT(workId) FROM [works] WHERE author=authorId) as sum                        
       FROM [authors]
     '));
     $grid->addColumn('name', 'Jméno');
     $grid->addColumn('surname', 'Příjmení')->addDefaultSorting('asc');
     $grid->addColumn('class', 'Maturita')->getCellPrototype()->style('text-align: center;');
     $grid->addColumn('classMark', 'Třída')->getCellPrototype()->style('text-align: right;');
     $grid->addColumn('sum', 'Počet prací')->getCellPrototype()->style('text-align: right;')->class('pages');
     $grid->addActionColumn('Akce');
     $grid->keyName = 'id';
     $grid->addAction('Smazat', 'delete!', NULL, FALSE, DataGridAction::WITH_KEY);
     $grid['name']->addFilter();
     $grid['surname']->addFilter();
     $grid['class']->addSelectboxFilter();
     $grid['classMark']->addSelectboxFilter();
     $grid['sum']->addSelectboxFilter();
     $grid->multiOrder = FALSE;
     $grid->itemsPerPage = $this->getCookiesItemsCount(15);
     $renderer = $grid->getRenderer();
     $renderer->paginatorFormat = '%label% %input% z %count%';
     $renderer->infoFormat = 'Autoři %from%. - %to%. z %count% | Zobrazit: %selectbox% | %reset%';
     $renderer->onRowRender[] = array($this, 'OnRowRendered');
     //$grid->rememberState = TRUE;
     $this->addComponent($grid, $name);
     return;
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:38,代码来源:AuthorList.php

示例3: __construct

    /**
     * Constractor creates connection and checks/creates tables stucture
     */
    public function __construct()
    {
        $dibiConfig = dibi::getConnection()->getConfig();
        $dbname = isset($dibiConfig['dbname']) ? $dibiConfig['dbname'] : $dibiConfig['database'];
        $config = array('driver' => 'sqlite', 'profiler' => Environment::getConfig('perform')->storage_profiler, 'database' => realpath(Environment::getConfig('perform')->modelCache) . '/' . $dbname . '-storage.sdb');
        parent::__construct($config, 'storage');
        if (!$this->getDatabaseInfo()->hasTable('fields')) {
            $this->query('CREATE TABLE [fields] ([id] INTEGER NOT NULL PRIMARY KEY,
		[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
		[hash] VARCHAR(32) NOT NULL, [type] VARCHAR(50));
		CREATE UNIQUE INDEX [fields_idx] on [fields] ( [name], [table]);');
        }
        if (!$this->getDatabaseInfo()->hasTable('tables')) {
            $this->query('CREATE TABLE [tables] ( [id] INTEGER NOT NULL PRIMARY KEY,
		[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
        }
        if (!$this->getDatabaseInfo()->hasTable('views')) {
            $this->query('CREATE TABLE [views] ( [id] INTEGER NOT NULL PRIMARY KEY,
		[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
        }
        if (!$this->getDatabaseInfo()->hasTable('indexes')) {
            $this->query('CREATE TABLE [indexes] ([id] INTEGER NOT NULL PRIMARY KEY,
		[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
		[hash] VARCHAR(32) NOT NULL, [unique] BOOLEAN);
		CREATE UNIQUE INDEX [indexes_idx] on [indexes] ( [name], [table]);');
        }
    }
开发者ID:Edke,项目名称:PerfORM,代码行数:30,代码来源:PerfORMStorage.php

示例4: setUp

 protected function setUp()
 {
     $this->db = dibi::getConnection("ormion");
     $this->db->delete("comments")->execute();
     $this->db->delete("pages")->execute();
     $this->db->query("insert into [pages]", array("name" => "Clanek", "description" => "Popis", "text" => "Text", "visits" => 0, "allowed" => true), array("name" => "Article", "description" => "Description", "text" => "Text emericky.", "visits" => 5, "allowed" => false), array("name" => "Nepovolený článek", "description" => "Popis nepovoleného článku", "text" => "Dlouhý text. By byl delší než tento.", "visits" => 3, "allowed" => false), array("name" => "Jinačí článek", "description" => "Ryze alternativní popis", "text" => "Duchaplný text.", "visits" => 8, "allowed" => true));
 }
开发者ID:janmarek,项目名称:Ormion,代码行数:7,代码来源:HasManyTest.php

示例5: setUp

 protected function setUp()
 {
     $this->db = dibi::getConnection("ormion");
     $this->db->delete("pages")->execute();
     // id, name, description, text, created, allowed
     $this->db->query("insert into [pages]", array("name" => "Clanek", "description" => "Popis", "text" => "Text", "visits" => 0, "allowed" => true), array("name" => "Article", "description" => "Description", "text" => "Text emericky.", "visits" => 5, "allowed" => false), array("name" => "Nepovolený článek", "description" => "Popis nepovoleného článku", "text" => "Dlouhý text. By byl delší než tento.", "visits" => 3, "allowed" => false), array("name" => "Jinačí článek", "description" => "Ryze alternativní popis", "text" => "Duchaplný text.", "visits" => 8, "allowed" => true));
     $fluent = $this->db->select("*")->from("pages");
     $this->object = new Ormion\Collection($fluent, "Page");
 }
开发者ID:janmarek,项目名称:Ormion,代码行数:9,代码来源:CollectionTest.php

示例6: createComponentDataGrid

 /**
  * Component factory.
  * @see Nette/ComponentContainer#createComponent()
  */
 protected function createComponentDataGrid($name)
 {
     $grid = new DataGrid();
     $grid->bindDataTable(dibi::getConnection()->dataSource('SELECT
     workId as id,        
     title,
     CONCAT_WS(" ", name, surname) as authorName,
     award,
     year,
     type,
     pages,
     added,
     edited
     FROM [works] 
     join [authors] on author = authorId', 'WHERE %and', $this->where));
     $grid->addActionColumn('Akce');
     $grid->addColumn('title', 'Název', 50)->addDefaultSorting('asc');
     if (!isset($this->where['authorId'])) {
         $grid->addColumn('authorName', 'Autor');
     }
     $grid->addNumericColumn('year', 'Ročník')->getCellPrototype()->style('min-width: 75px;');
     $grid->addDateColumn('added', 'Vytvořena', '%d.%m.%Y');
     $grid->addDateColumn('edited', 'Upravena', '%H:%M:%S %d.%m.%Y')->getCellPrototype()->style('white-space: nowrap;');
     $grid->addColumn('award', 'Cena');
     $grid->addColumn('type', 'Typ');
     $grid->addNumericColumn('pages', 'Stran')->getCellPrototype()->style('text-align: right;')->class = 'pages';
     $grid->keyName = 'id';
     $grid->addAction('Smazat', 'delete!', NULL, FALSE, DataGridAction::WITH_KEY);
     if ($this->advanced) {
         $grid['title']->addFilter();
         $grid['authorName']->addFilter();
         $grid['year']->addSelectboxFilter();
         $grid['award']->addSelectboxFilter();
         $grid['type']->addSelectboxFilter();
         $grid['type']->addSelectboxFilter();
         $grid['added']->addDateFilter();
         $grid['edited']->addDateFilter();
         if (isset($grid['pages'])) {
             $grid['pages']->addSelectboxFilter();
         }
     }
     //$grid->itemsPerPage = ;
     $grid->multiOrder = FALSE;
     $grid->itemsPerPage = $this->getCookiesItemsCount(15);
     $renderer = $grid->getRenderer();
     $renderer->paginatorFormat = '%label% %input% z %count%';
     $renderer->infoFormat = 'Práce %from% - %to% z %count% | Zobrazit: %selectbox% | %reset%';
     $renderer->onRowRender[] = array($this, 'worksOnRowRendered');
     if (!$grid->paginator->itemCount) {
         $renderer->wrappers['form']['.class'] .= " hidden";
     }
     //$grid->rememberState = TRUE;
     $this->addComponent($grid, $name);
     return;
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:59,代码来源:WorkList.php

示例7: __construct

 /**
  * @param  string  SQL command or table name, as data source
  * @param  DibiConnection  connection
  */
 public function __construct($sql, DibiConnection $connection = NULL)
 {
     if (strpos($sql, ' ') === FALSE) {
         // table name
         $this->sql = $sql;
     } else {
         // SQL command
         $this->sql = '(' . $sql . ') AS [source]';
     }
     $this->connection = $connection === NULL ? dibi::getConnection() : $connection;
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:15,代码来源:DibiDataSource.php

示例8: connect

 /**
  * Connect to DB, inherit credentials from constructor
  */
 private function connect()
 {
     $this->connectionId = 'DB_CONNECTION_' . md5(implode(',', $this->credentials));
     if (defined($this->connectionId) === FALSE) {
         $connection = dibi::connect($this->credentials, $this->connectionId);
         // Tracy panel
         if (TRACY === TRUE) {
             $panel = new Dibi\Bridges\Tracy\Panel();
             $panel->register($connection);
         }
         define($this->connectionId, TRUE);
     }
     $this->connection = dibi::getConnection($this->connectionId);
 }
开发者ID:allyse,项目名称:allyse,代码行数:17,代码来源:Db.php

示例9: generatedConfig

 private function generatedConfig()
 {
     $tableInfo = dibi::getConnection("ormion")->getDatabaseInfo()->getTable("pages");
     $cfg = Ormion\Config::fromTableInfo($tableInfo);
     $this->assertEquals(array("id", "name", "description", "text", "visits", "created", "allowed"), $cfg->getColumns());
     $this->assertEquals(dibi::TEXT, $cfg->getType("name"));
     $this->assertEquals(dibi::INTEGER, $cfg->getType("id"));
     $this->assertEquals(dibi::TIME, $cfg->getType("created"));
     $this->assertEquals(dibi::BOOL, $cfg->getType("allowed"));
     $this->assertTrue($cfg->isNullable("description"));
     $this->assertFalse($cfg->isNullable("text"));
     $this->assertFalse($cfg->isNullable("name"));
     $this->assertTrue($cfg->isPrimaryAutoIncrement());
     $this->assertEquals("id", $cfg->getPrimaryColumn());
 }
开发者ID:janmarek,项目名称:Ormion,代码行数:15,代码来源:ConfigTest.php

示例10: createComponentWorks

 protected function createComponentWorks($name)
 {
     //url as link,
     //title,
     $grid = new DataGrid();
     $grid->bindDataTable(dibi::getConnection()->dataSource('SELECT
       url as link,
       authorUrl,
       title,
       award,
       year,', Model::sqlWorkClassName() . 'as workClass,', 'type,                                     
       pages,
       [read]
       FROM [works]
       JOIN [authors] on author = authorId 
       WHERE authorUrl=%s', $this->id));
     $grid->addColumn('title', 'Název')->addDefaultSorting('asc')->getCellPrototype()->addClass('first');
     $grid->addNumericColumn('year', 'Rok')->getCellPrototype()->style('text-align: center;');
     $grid->addColumn('workClass', 'Třída')->getCellPrototype()->style('text-align: center;');
     $grid->addColumn('award', 'Ocenění');
     $grid->addColumn('type', 'Typ');
     $grid->addNumericColumn('pages', 'Stran')->getCellPrototype()->style('text-align: right');
     $grid->addColumn('read', 'Čtenost')->getCellPrototype()->style('text-align: right;');
     /*
           $grid->addActionColumn('Akce');
           $grid['title']->addFilter();
           $grid['authorName']->addFilter();
           $grid['year']->addSelectboxFilter();
           $grid['award']->addSelectboxFilter();
           $grid['type']->addSelectboxFilter();
           $grid['pages']->addSelectboxFilter();  */
     $grid->itemsPerPage = 0;
     $grid->multiOrder = FALSE;
     $renderer = $grid->getRenderer();
     $renderer->paginatorFormat = '%label% %input% z %count%';
     $renderer->infoFormat = 'Práce %from% - %to% z %count% | Zobrazit: %selectbox% | %reset%';
     $renderer->onRowRender[] = array($this, 'worksOnRowRendered');
     //$renderer->onCellRender[] = array($this, 'gridOnCellRendered');
     //$grid->rememberState = TRUE;
     return $grid;
     //$this->addComponent($grid, $name);
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:42,代码来源:AuthorPresenter.php

示例11: createComponentAuthors

 protected function createComponentAuthors($name)
 {
     $grid = new DataGrid();
     $search = "";
     if (isset($this->searchFull)) {
         foreach ($this->search as $one) {
             //$search .= "name LIKE '%".$one."%' OR surname LIKE '% ".$one."%' OR ";
             $search .= "name RLIKE '(^| ){$one}' OR surname RLIKE '(^| ){$one}' OR ";
         }
         foreach ($this->searchFull as $one) {
             $search .= "name RLIKE '(^| )" . $one . " ' OR surname RLIKE '(^| )" . $one . " ' OR ";
         }
         $search = substr($search, 0, -3);
     }
     $grid->bindDataTable(dibi::getConnection()->dataSource('SELECT
         authorUrl as link,
         name,
         surname,', $this->formColumns(array('class')), Model::sqlClassName(Model::getSchoolYear()) . 'as classMark,', Model::sqlSumWorks() . 'as [sum],', Model::sqlSumReads() . 'as [read]', 'FROM [authors]', 'WHERE %and', $this->where, '%if', isset($search), 'AND %sql', $search, '%end'));
     $grid->addColumn('name', 'Jméno')->getCellPrototype()->addClass('first');
     $grid->addColumn('surname', 'Příjmení')->addDefaultSorting('asc');
     if ($this->notCol('class')) {
         $grid->addColumn('class', 'Maturita')->getCellPrototype()->style('text-align: center;');
     }
     $grid->addColumn('classMark', 'Třída')->getCellPrototype()->style('text-align: right;');
     $grid->addColumn('sum', 'Počet prací')->getCellPrototype()->style('text-align: right;');
     $grid->addColumn('read', 'Čtenost')->getCellPrototype()->style('text-align: right;');
     $grid->multiOrder = FALSE;
     $grid->displayedItems = array('vše', 5, 8, 10, 20, 50, 100);
     $grid->itemsPerPage = $this->getCookiesItemsCount(8);
     $grid->nothingMessage = "Žádný autor nebyl nalezen.";
     $grid->hiddenFiltering = TRUE;
     $renderer = $grid->getRenderer();
     $renderer->paginatorFormat = '%label% %input% z %count%';
     $renderer->infoFormat = 'Autoři %from% - %to% z %count% | Zobrazit: %selectbox% | %reset%';
     $renderer->onRowRender[] = array($this, 'authorsOnRowRendered');
     //$renderer->onCellRender[] = array($this, 'gridOnCellRendered');
     return $grid;
     //$this->addComponent($grid, $name);
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:39,代码来源:DefaultPresenter.php

示例12: date_default_timezone_set

<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Query Language Named Arguments Examples | dibi</h1>

<?php 
require __DIR__ . '/../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite3', 'database' => 'data/sample.s3db'));
dibi::getConnection()->getSubstitutes()->test = 'test_';
dibi::getConnection()->getSubstitutes()->{''} = 'testtoo_';
// SELECT
$name = 'K%';
$timestamp = mktime(0, 0, 0, 10, 13, 1997);
$id_list = array(1, 2, 3);
// If the argument implements IDibiArguments, it is removed from the arguments
// and added to the named argument collections.
// If the %nmd modifier is used for a positional argument, it is also added
// to the named argument collections. It should be an array or object implementing
// the ArrayAccess interface.
// Any named argument is a colon with identifier with optional percent sign and
// value modifier.
// Original substitutions are still present.
dibi::test('
	SELECT COUNT(*) as [count]
	%nmd
	FROM [:test:customers]
	WHERE [name] LIKE :name
	AND [added] > :timestamp%d
	OR [customer_id] IN :id_list%in
	ORDER BY [name]', new ArrayObject(['timestamp' => new DibiDateTime($timestamp)]), new DibiArguments(['name' => $name, 'id_list' => $id_list]));
开发者ID:jakubmacek,项目名称:dibi,代码行数:30,代码来源:query-language-named-arguments.php

示例13: disconnect

 public static function disconnect()
 {
     dibi::getConnection()->disconnect();
 }
开发者ID:romansklenar,项目名称:nette-datagrid,代码行数:4,代码来源:BaseModel.php

示例14: init

 public static function init()
 {
     return new self(dibi::getConnection(), NEnvironment::getCache(), NEnvironment::getContext());
 }
开发者ID:oaki,项目名称:demoshop,代码行数:4,代码来源:PaymentModelold.php

示例15: getManager

 /**
  * Entity manager factory
  *
  * @param DibiConnection $connection
  * @return ActiveMapper\Manager
  */
 public static function getManager(DibiConnection $connection = NULL)
 {
     if ($connection == NULL) {
         $connection = \dibi::getConnection();
     }
     return new static($connection);
 }
开发者ID:nella,项目名称:ActiveMapper,代码行数:13,代码来源:Manager.php


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