getConnection() public static method

Retrieve active connection.
public static getConnection ( $name = NULL ) : Dibi\Connection
return Dibi\Connection
Exemplo n.º 1
0
 public function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->db = dibi::getConnection();
     self::$count++;
     //		$this->setWebloaderPaths();
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
    /**
     * 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]);');
        }
    }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 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");
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 /**
  * @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;
 }
Exemplo n.º 8
0
Arquivo: Db.php Projeto: allyse/allyse
 /**
  * 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);
 }
Exemplo n.º 9
0
 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());
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 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);
 }
<!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]));
Exemplo n.º 13
0
 public static function disconnect()
 {
     dibi::getConnection()->disconnect();
 }
Exemplo n.º 14
0
 public static function init()
 {
     return new self(dibi::getConnection(), NEnvironment::getCache(), NEnvironment::getContext());
 }
Exemplo n.º 15
0
 /**
  * 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);
 }
Exemplo n.º 16
0
<?php

namespace App;

require_once __DIR__ . "/bootstrap.php";
use Nette\Debug, Nette\Framework, dibi;
Debug::timer('benchmark');
$memory = memory_get_peak_usage();
echoBeginHtml();
/********************************************************************************************************************************/
// Setum entity manager
$em = new \ActiveMapper\Manager(\dibi::getConnection());
echo "<h1>All authors</h1>";
// Get all authors
$authors = $em->findAll('App\\Models\\Author');
foreach ($authors as $author) {
    Debug::dump($author->name);
    Debug::dump($author->blog->name);
}
echo "<h1>Author by ID #3</h1>";
// Get author by id
$author = $em->find('App\\Models\\Author', 3);
Debug::dump($author->name);
Debug::dump($author->blog->name);
/********************************************************************************************************************************/
// Benchmark data
Debug::barDump(Framework::NAME . " " . Framework::VERSION . " " . Framework::REVISION);
Debug::barDump("dibi " . dibi::VERSION . " " . dibi::REVISION);
Debug::barDump($mappingTime = number_format(Debug::timer('benchmark') * 1000, 1, '.', ' ') . "ms", "Mapping Time");
Debug::barDump($mappingMemory = number_format((memory_get_peak_usage() - $memory) / 1000, 1, '.', ' ') . "kB", "Mapping Memory");
echo '<p><a href="http://github.com/Vrtak-CZ/ActiveMapper/blob/master/examples/index.php" target="_blank">' . 'Show code on GitHub</a> - <a href="http://am.vrtak-cz.net/coverage">Show coverage</a></p>';
Exemplo n.º 17
0
 public function __construct()
 {
     $this->connection = dibi::getConnection();
 }
Exemplo n.º 18
0
 /**
  * Getter for dibi connection
  * @return DibiConnection
  */
 public static function getConnection()
 {
     if (!self::$connection) {
         self::$connection = dibi::getConnection();
     }
     return self::$connection;
 }
Exemplo n.º 19
0
 public function __construct()
 {
     parent::__construct('', \dibi::getConnection());
 }
Exemplo n.º 20
0
 public function copyTmpRecordToMd()
 {
     setMickaLog("Copy record to TMP", 'DEBUG', 'MdRecord.copyTmpRecordToMd');
     $rs = array();
     if (isset($this->md_record['md']) === FALSE || count($this->md_record['md']['RECNO']) < 1) {
         setMickaLog("Record not found", 'ERROR', 'MdRecord.copyTmpRecordToMp');
         $rs['report'] = 'Record not found';
         return $rs;
     }
     if ($this->md_record['user_right'] != 'w' || $this->user == 'guest') {
         setMickaLog("Not rights", 'ERROR', 'MdRecord.copyTmpRecordToMp');
         $rs['report'] = 'Not rights';
         return $rs;
     }
     // data z tmp
     $recno_tmp = $this->md_record['md']['RECNO'];
     $this->setTableMode('tmp');
     $md = $this->getMd($where_col = 'recno', $where_value = $recno_tmp);
     $data_tmp = array();
     $data_tmp = $this->md_record['md'];
     // data z md
     $this->setTableMode('md');
     $tmp_table_md_values = TMPTABLE_PREFIX . '_md_values';
     $md = $this->getMd($where_col = 'uuid', $where_value = $data_tmp['UUID']);
     if ($md['report'] == 'Record not found') {
         // Nový záznam
         setMickaLog("New record to MD", 'DEBUG', 'MdRecord.copyTmpRecordToMp');
         $data['uuid'] = $data_tmp['UUID'];
         $data['md_standard'] = $data_tmp['MD_STANDARD'];
         $data['lang'] = 'eng';
         // FIXME: optimalizace
         $data_md = array();
         $recno = $this->setNewMd($data);
         $data_md['lang'] = $data_tmp['LANG'];
         $data_md['data_type'] = $data_tmp['DATA_TYPE'];
         $data_md['last_update_user'] = $this->user;
         $data_md['last_update_date'] = DB_DRIVER == 'mssql2005' ? str_replace('-', '', getNewDate()) : getNewDate();
         $data_md['edit_group'] = $data_tmp['EDIT_GROUP'] != '' ? $data_tmp['EDIT_GROUP'] : $this->user;
         $data_md['view_group'] = $data_tmp['VIEW_GROUP'] != '' ? $data_tmp['VIEW_GROUP'] : $this->user;
         $data_md['x1'] = $data_tmp['X1'] != '' ? $data_tmp['X1'] : NULL;
         $data_md['y1'] = $data_tmp['Y1'] != '' ? $data_tmp['Y1'] : NULL;
         $data_md['x2'] = $data_tmp['X2'] != '' ? $data_tmp['X2'] : NULL;
         $data_md['y2'] = $data_tmp['Y2'] != '' ? $data_tmp['Y2'] : NULL;
         $data_md['the_geom'] = $data_tmp['THE_GEOM'] != '' ? $data_tmp['THE_GEOM'] : NULL;
         $data_md['range_begin'] = $data_tmp['RANGE_BEGIN'] != '' ? $data_tmp['RANGE_BEGIN']->format('Y-m-d') : NULL;
         $data_md['range_end'] = $data_tmp['RANGE_END'] != '' ? $data_tmp['RANGE_END']->format('Y-m-d') : NULL;
         $data_md['md_update'] = $data_tmp['MD_UPDATE'] != '' ? $data_tmp['MD_UPDATE'] : NULL;
         $data_md['title'] = $data_tmp['TITLE'] != '' ? $data_tmp['TITLE'] : NULL;
         $data_md['valid'] = $data_tmp['VALID'];
         $data_md['prim'] = $data_tmp['PRIM'];
         if (DB_DRIVER == 'oracle') {
             $xml = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
             if ($xml != '') {
                 $conn = dibi::getConnection()->driver->getResource();
                 setXmlToClob($conn, $this->table_md, 'xmldata', "recno={$recno}", $xml);
             }
         } elseif (DB_DRIVER == 'postgre') {
             //$data_md['pxml%sql'] = ($data_tmp['PXML'] != '') ? "XMLPARSE(DOCUMENT '" . $data_tmp['PXML'] . "')" : NULL;
             $data_md['xmldata'] = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
         } elseif (DB_DRIVER == 'mssql2005') {
             $data_md['xmldata'] = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
         } else {
             $data_md['pxml'] = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
         }
         $this->setMd($recno, $data_md);
         setXmldata2Pxml($this->table_md, $recno);
         $sql = array();
         array_push($sql, "\n\t\t\t\tINSERT INTO md_values (recno, md_id, md_value, md_path, lang , package_id)\n\t\t\t\tSELECT %i, md_id, md_value, md_path, lang , package_id FROM {$tmp_table_md_values} WHERE recno=%i\n\t\t\t", $recno, $recno_tmp);
         $result = _executeSql('insert', $sql, array('all'));
     } elseif ($md['report'] == 'ok' && $md['right'] == 'w') {
         // Update záznamu
         $data_md = array();
         $recno = $md['md']['RECNO'];
         $data_md['lang'] = $data_tmp['LANG'];
         $data_md['data_type'] = $data_tmp['DATA_TYPE'];
         $data_md['last_update_user'] = $this->user;
         $data_md['last_update_date'] = DB_DRIVER == 'mssql2005' ? str_replace('-', '', getNewDate()) : getNewDate();
         $data_md['edit_group'] = $data_tmp['EDIT_GROUP'] != '' ? $data_tmp['EDIT_GROUP'] : $this->user;
         $data_md['view_group'] = $data_tmp['VIEW_GROUP'] != '' ? $data_tmp['VIEW_GROUP'] : $this->user;
         $data_md['x1'] = $data_tmp['X1'] != '' ? $data_tmp['X1'] : NULL;
         $data_md['y1'] = $data_tmp['Y1'] != '' ? $data_tmp['Y1'] : NULL;
         $data_md['x2'] = $data_tmp['X2'] != '' ? $data_tmp['X2'] : NULL;
         $data_md['y2'] = $data_tmp['Y2'] != '' ? $data_tmp['Y2'] : NULL;
         $data_md['the_geom'] = $data_tmp['THE_GEOM'] != '' ? $data_tmp['THE_GEOM'] : NULL;
         $data_md['range_begin'] = $data_tmp['RANGE_BEGIN'] != '' ? $data_tmp['RANGE_BEGIN']->format('Y-m-d') : NULL;
         $data_md['range_end'] = $data_tmp['RANGE_END'] != '' ? $data_tmp['RANGE_END']->format('Y-m-d') : NULL;
         $data_md['md_update'] = $data_tmp['MD_UPDATE'] != '' ? $data_tmp['MD_UPDATE'] : NULL;
         $data_md['title'] = $data_tmp['TITLE'] != '' ? $data_tmp['TITLE'] : NULL;
         $data_md['valid'] = $data_tmp['VALID'];
         $data_md['prim'] = $data_tmp['PRIM'];
         if (DB_DRIVER == 'oracle') {
             //$data_md['pxml%sql'] = ($data_tmp['PXML'] != '') ? "XMLType('" . $data_tmp['PXML'] . "')" : NULL;
             $xml = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
             if ($xml != '') {
                 $conn = dibi::getConnection()->driver->getResource();
                 setXmlToClob($conn, $this->table_md, 'xmldata', "recno={$recno}", $xml);
             }
         } elseif (DB_DRIVER == 'postgre') {
             //$data_md['pxml%sql'] = ($data_tmp['PXML'] != '') ? "XMLPARSE(DOCUMENT '" . $data_tmp['PXML'] . "')" : NULL;
             $data_md['xmldata'] = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
         } elseif (DB_DRIVER == 'mssql2005') {
             $data_md['xmldata'] = $data_tmp['PXML'] != '' ? $data_tmp['PXML'] : NULL;
         } else {
             //$data_md['pxml'] = ($data_tmp['PXML'] != '') ? $data_tmp['PXML'] : NULL;
         }
         $this->setMd($recno, $data_md);
         setXmldata2Pxml($this->table_md, $recno);
         $this->deleteMdValues($recno, 100, -1, -1, array());
         $sql = array();
         array_push($sql, "\n\t\t\t\tINSERT INTO md_values (recno, md_id, md_value, md_path, lang , package_id)\n\t\t\t\tSELECT %i, md_id, md_value, md_path, lang , package_id FROM {$tmp_table_md_values} WHERE recno=%i\n\t\t\t", $recno, $recno_tmp);
         $result = _executeSql('insert', $sql, array('all'));
     } else {
         $rs['report'] = $md['report'];
         return $rs;
     }
     unset($md);
     $rs['report'] = 'ok';
     return $rs;
 }
Exemplo n.º 21
0
 /**
  * Table constructor.
  * @param  DibiConnection
  * @return void
  */
 public function __construct(DibiConnection $connection = NULL)
 {
     $this->connection = $connection === NULL ? dibi::getConnection() : $connection;
     $this->setup();
 }
Exemplo n.º 22
0
 public static function init()
 {
     return new self(dibi::getConnection(), NEnvironment::getCache(self::MODULE_NAME));
 }
Exemplo n.º 23
0
 /** @return DibiConnection */
 public function createDibi()
 {
     return dibi::getConnection();
 }