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


PHP Database\Helpers类代码示例

本文整理汇总了PHP中Nette\Database\Helpers的典型用法代码示例。如果您正苦于以下问题:PHP Helpers类的具体用法?PHP Helpers怎么用?PHP Helpers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 public function __construct()
 {
     $connection = new \Nette\Database\Connection('mysql:host=127.0.0.1;dbname=test', 'root', '');
     \Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/sql/db.sql');
     $structure = new \Nette\Database\Structure($connection, new \Nette\Caching\Storages\FileStorage(__DIR__ . '/../../temp/'));
     $conventions = new \Nette\Database\Conventions\DiscoveredConventions($structure);
     $this->database = new \Nette\Database\Context($connection, $structure, $conventions, new \Nette\Caching\Storages\FileStorage(__DIR__ . '/../../temp/'));
     $this->cache = new Nette\Caching\Storages\FileStorage(__DIR__ . '/../../temp');
 }
开发者ID:kravcik,项目名称:core,代码行数:9,代码来源:Service.php

示例2: processQuery

 /**
  * @param array
  * @return string
  */
 protected function processQuery(array $query)
 {
     $s = '';
     list($sql, $params, $time) = $query;
     $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
     $s .= '</td><td class="nette-Doctrine2Panel-sql">' . Helpers::dumpSql($sql);
     $s .= '</td><td>' . Dumper::toHtml($params) . '</tr>';
     return $s;
 }
开发者ID:pipaslot,项目名称:doctrine,代码行数:13,代码来源:QueryPanel.php

示例3: getPanel

    public function getPanel()
    {
        $this->disabled = TRUE;
        $s = '';
        $h = 'htmlSpecialChars';
        foreach ($this->queries as $i => $query) {
            list($sql, $params, $time, $rows, $connection, $source) = $query;
            $explain = NULL;
            // EXPLAIN is called here to work SELECT FOUND_ROWS()
            if ($this->explain && preg_match('#\\s*\\(?\\s*SELECT\\s#iA', $sql)) {
                try {
                    $cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
                    $explain = $connection->queryArgs("{$cmd} {$sql}", $params)->fetchAll();
                } catch (\PDOException $e) {
                }
            }
            $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
            if ($explain) {
                static $counter;
                $counter++;
                $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-{$counter}'>explain&nbsp;&#x25ba;</a>";
            }
            $s .= '</td><td class="nette-DbConnectionPanel-sql">' . Helpers::dumpSql(self::$maxLength ? Nette\Utils\Strings::truncate($sql, self::$maxLength) : $sql);
            if ($explain) {
                $s .= "<table id='nette-DbConnectionPanel-row-{$counter}' class='nette-collapsed'><tr>";
                foreach ($explain[0] as $col => $foo) {
                    $s .= "<th>{$h($col)}</th>";
                }
                $s .= "</tr>";
                foreach ($explain as $row) {
                    $s .= "<tr>";
                    foreach ($row as $col) {
                        $s .= "<td>{$h($col)}</td>";
                    }
                    $s .= "</tr>";
                }
                $s .= "</table>";
            }
            if ($source) {
                $s .= Nette\Diagnostics\Helpers::editorLink($source[0], $source[1])->class('nette-DbConnectionPanel-source');
            }
            $s .= '</td><td>';
            foreach ($params as $param) {
                $s .= Debugger::dump($param, TRUE);
            }
            $s .= '</td><td>' . $rows . '</td></tr>';
        }
        return empty($this->queries) ? '' : '<style> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important }
			#nette-debug nette-DbConnectionPanel tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
			<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
    }
开发者ID:exesek,项目名称:nette20login,代码行数:57,代码来源:ConnectionPanel.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $connection = $this->database->getConnection();
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_USERS_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_ROLES_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_RESOURCES_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_USER_ROLE_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_USER_REQUEST_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_ROLES_DATA_TABLE));
     Nette\Database\Helpers::loadFromFile($connection, $this->getFile(static::FILE_IDENTITY_HASH_TABLE));
 }
开发者ID:trejjam,项目名称:authorization,代码行数:11,代码来源:Install.php

示例5: getTables

 /**
  * @return array
  */
 protected function getTables()
 {
     $tables = [];
     foreach ($this->structure->getTables() as $table) {
         if ($table['view'] === FALSE) {
             foreach ($this->structure->getColumns($table['name']) as $column) {
                 $tables[$table['name']][$column['name']] = \Nette\Database\Helpers::detectType($column['nativetype']);
             }
         }
     }
     return $tables;
 }
开发者ID:filsedla,项目名称:hyperrow,代码行数:15,代码来源:Generator.php

示例6: renderException

 public static function renderException($e)
 {
     if (!$e instanceof \PDOException) {
         return;
     }
     if (isset($e->queryString)) {
         $sql = $e->queryString;
     } elseif ($item = Tracy\Helpers::findTrace($e->getTrace(), 'PDO::prepare')) {
         $sql = $item['args'][0];
     }
     return isset($sql) ? ['tab' => 'SQL', 'panel' => Helpers::dumpSql($sql)] : NULL;
 }
开发者ID:ricco24,项目名称:database,代码行数:12,代码来源:ConnectionPanel.php

示例7: __testbench_ndb_setupDatabase

 /** @internal */
 private function __testbench_ndb_setupDatabase(Connection $db, $container)
 {
     $this->__testbench_ndb_databaseName = 'db_tests_' . getmypid();
     $this->__testbench_ndb_dropDatabase($db);
     $this->__testbench_ndb_createDatabase($db);
     if (isset($container->parameters['testbench']['sqls'])) {
         foreach ($container->parameters['testbench']['sqls'] as $file) {
             \Nette\Database\Helpers::loadFromFile($db, $file);
         }
     }
     register_shutdown_function(function () use($db) {
         $this->__testbench_ndb_dropDatabase($db);
     });
 }
开发者ID:jakubskrz,项目名称:testbench,代码行数:15,代码来源:TNetteDatabase.php

示例8: __testbench_database_setup

 /** @internal */
 public function __testbench_database_setup($connection, \Nette\DI\Container $container, $persistent = FALSE)
 {
     $config = $container->parameters['testbench'];
     $this->__testbench_databaseName = $config['dbprefix'] . getenv(\Tester\Environment::THREAD);
     $this->__testbench_database_drop($connection, $container);
     $this->__testbench_database_create($connection, $container);
     foreach ($config['sqls'] as $file) {
         \Nette\Database\Helpers::loadFromFile($connection, $file);
     }
     if ($persistent === FALSE) {
         register_shutdown_function(function () use($connection, $container) {
             $this->__testbench_database_drop($connection, $container);
         });
     }
 }
开发者ID:mrtnzlml,项目名称:testbench,代码行数:16,代码来源:NetteDatabaseConnectionMock.php

示例9: getPanel

    /**
     * @return string
     */
    public function getPanel()
    {
        $output = '';
        foreach ($this->queries as $record) {
            $time = $record['time'];
            $query = $record['query'];
            $output .= '<tr><td>';
            $output .= $time ? $time . '&nbsp;ms' : 'null';
            $output .= '</td><td>' . Helpers::dumpSql($query);
            $output .= '</td></tr>';
        }
        return empty($this->queries) ? '' : '<style> #tracy-debug .tracy-PropelPanel tr table { margin: 8px 0; max-height: 150px; overflow:auto }</style>
			<h1>Channel: ' . htmlSpecialChars($this->channelName, ENT_QUOTES, 'UTF-8') . ' | Queries: ' . htmlSpecialChars($this->profiledQueriesCounter, ENT_QUOTES, 'UTF-8') . ' / ' . htmlSpecialChars($this->unprofiledQueriesCounter, ENT_QUOTES, 'UTF-8') . ' | Time: ' . htmlSpecialChars($this->totalTime, ENT_QUOTES, 'UTF-8') . 'ms</h1>
			<div class="tracy-inner tracy-PropelPanel" style="max-width: 800px;">
			<table>
				<tr><th>Time</th><th>SQL Statement</th></tr>' . $output . '
			</table>
			</div>';
    }
开发者ID:divisions-etch,项目名称:nette-propel2-extension,代码行数:22,代码来源:PropelPanel.php

示例10: getPanel

 public function getPanel()
 {
     global $wpdb;
     $inner = '';
     foreach ($wpdb->queries as $q) {
         $query = \Nette\Database\Helpers::dumpSql($q[0]);
         $time = round($q[1] * 100000) / 1000;
         $files = $q[2];
         $callstack = explode(', ', $q[2]);
         array_shift($callstack);
         array_shift($callstack);
         array_shift($callstack);
         foreach ($callstack as &$row) {
             $row = htmlspecialchars($row);
         }
         unset($row);
         $callstack = implode('<br>', $callstack);
         $inner .= "<tr><td rowspan='2'>{$time}</td><td><code>{$query}</code></td></tr><tr><td><code style='font-size:.8em'>{$callstack}</code></td></tr>";
     }
     $panelHtml = "\n\t\t<h1>WordPress SQL</h1>\n\t\t<div class='tracy-inner nette-DbConnectionPanel'>\n\t\t\t<table>\n\t\t\t\t<tr><th>Time&nbsp;ms</th><th>SQL Query</th></tr>\n\t\t\t\t\t{$inner}\n\t\t\t</table>\n\t\t</div>\n\t\t";
     return $panelHtml;
 }
开发者ID:manGoweb,项目名称:MangoPressSqlPanel,代码行数:22,代码来源:MangoPressSqlPanel.php

示例11: logQuery

 public function logQuery(Connection $connection, $result)
 {
     if (!$result instanceof ResultSet) {
         return;
     }
     $queryString = $result->getQueryString();
     if (Strings::startsWith($queryString, 'EXPLAIN')) {
         return;
     }
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = array($row['file'], (int) $row['line']);
             break;
         }
     }
     $sqlQuery = Helpers::dumpSql($queryString, $result->getParameters(), $connection);
     $this->queries[$sqlQuery][] = array($sqlQuery, $source);
 }
开发者ID:RELIGIS,项目名称:DuplicateQueriesPanel,代码行数:23,代码来源:DuplicateQueriesPanel.php

示例12: getPanel

        function getPanel()
        {
            $this->disabled = TRUE;
            $s = '';
            foreach ($this->queries as $query) {
                list($sql, $params, $time, $rows, $connection, $source) = $query;
                $explain = NULL;
                if ($this->explain && preg_match('#\\s*\\(?\\s*SELECT\\s#iA', $sql)) {
                    try {
                        $cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
                        $explain = $connection->queryArgs("{$cmd} {$sql}", $params)->fetchAll();
                    } catch (\PDOException $e) {
                    }
                }
                $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
                if ($explain) {
                    static $counter;
                    $counter++;
                    $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-{$counter}'>explain&nbsp;&#x25ba;</a>";
                }
                $s .= '</td><td class="nette-DbConnectionPanel-sql">' . Helpers::dumpSql(self::$maxLength ? Nette\Utils\Strings::truncate($sql, self::$maxLength) : $sql);
                if ($explain) {
                    $s .= "<table id='nette-DbConnectionPanel-row-{$counter}' class='nette-collapsed'><tr>";
                    foreach ($explain[0] as $col => $foo) {
                        $s .= '<th>' . htmlSpecialChars($col) . '</th>';
                    }
                    $s .= "</tr>";
                    foreach ($explain as $row) {
                        $s .= "<tr>";
                        foreach ($row as $col) {
                            $s .= '<td>' . htmlSpecialChars($col) . '</td>';
                        }
                        $s .= "</tr>";
                    }
                    $s .= "</table>";
                }
                if ($source) {
                    $s .= Nette\Diagnostics\Helpers::editorLink($source[0], $source[1])->class('nette-DbConnectionPanel-source');
                }
                $s .= '</td><td>';
                foreach ($params as $param) {
                    $s .= Debugger::dump($param, TRUE);
                }
                $s .= '</td><td>' . $rows . '</td></tr>';
            }
            return $this->count ? '<style class="nette-debug"> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important } </style>
			<h1 title="' . htmlSpecialChars($connection->getDsn()) . '">Queries: ' . $this->count . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . ', ' . htmlSpecialChars($this->name) . '</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>' . (count($this->queries) < $this->count ? '<p>...and more</p>' : '') . '</div>' : '';
        }
开发者ID:nakoukal,项目名称:raspi_www,代码行数:53,代码来源:nette.min.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $connection = $this->database->getConnection();
     $driverName = $connection->getPdo()->getAttribute(\PDO::ATTR_DRIVER_NAME);
     Nette\Database\Helpers::loadFromFile($connection, $this->getFileName($driverName . '.' . static::FILE_LABELS_TABLE));
 }
开发者ID:trejjam,项目名称:utils,代码行数:6,代码来源:Install.php

示例14: getQuery

 /**
  * Actual formatted query, e.g. 'SELECT * FROM ...'
  *
  * @return Html|string
  */
 public function getQuery()
 {
     $html = trim(Nette\Database\Helpers::dumpSql($this->query, $this->bindings));
     return Html::el()->setHtml($html);
 }
开发者ID:rikiless,项目名称:tracy-query-panel,代码行数:10,代码来源:EloquentHandler.php

示例15: dump

 /**
  * Displays complete result set as HTML table for debug purposes.
  *
  * @return void
  */
 public function dump()
 {
     Helpers::dumpResult($this);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:9,代码来源:Statement.php


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