本文整理汇总了PHP中Nette\Database\Helpers::loadFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::loadFromFile方法的具体用法?PHP Helpers::loadFromFile怎么用?PHP Helpers::loadFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Helpers
的用法示例。
在下文中一共展示了Helpers::loadFromFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例2: 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));
}
示例3: __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);
});
}
示例4: __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);
});
}
}
示例5: 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));
}
示例6: set_time_limit
require_once __DIR__ . "/libs/Curl.php";
require_once __DIR__ . "/libs/CurlResponse.php";
require_once __DIR__ . "/libs/Parser.php";
use Nette\Diagnostics\Debugger;
set_time_limit(0);
Debugger::enable(Debugger::DEVELOPMENT, __DIR__);
Debugger::timer();
/************************************ SQLite *************************************/
/*if (file_exists(__DIR__."/db.sqlite")) {
copy(__DIR__."/db.sqlite", __DIR__."/backup/".date("Y-m-d_H-i-s-").substr(microtime(TRUE)-time(), 2, 4).".sqlite");
}
$connection = new \Nette\Database\Connection('sqlite:' . __DIR__ . '/db.sqlite');
\Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.sqlite.sql');
/************************************ MySQL *************************************/
$connection = new \Nette\Database\Connection('mysql:host=localhost;dbname=njlogparser', 'nette', 'nette');
\Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.mysql.sql');
if (!defined('STDIN')) {
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Nette Jabber Log Parser</title></head><body><code><pre>';
}
$parser = new Parser($connection);
$parser->originalDataDir = __DIR__ . "/data";
//$parser->debug = TRUE;
$factory = new \Nette\Http\RequestFactory();
$factory->setEncoding('UTF-8');
$req = $factory->createHttpRequest();
if (($date = $req->getQuery('date', NULL)) || ($date = isset($argv[1]) ? $argv[1] : NULL)) {
$parser->parseDate($date, TRUE);
} else {
$parser->parse(10);
}
echo "\n\n";
示例7: catch
<?php
/**
* Test: Nette\Database test boostap.
*
* @author Jakub Vrana
* @author Jan Skrasek
* @package Nette\Caching
* @subpackage UnitTests
*/
use Nette\Database;
require __DIR__ . '/../bootstrap.php';
try {
$connection = new Database\Connection('mysql:host=localhost', 'root');
Database\Helpers::loadFromFile($connection, __DIR__ . '/nette_test.sql');
} catch (PDOException $e) {
TestHelpers::skip('Requires corretly configured mysql connection and "nette_test" database.');
}
示例8: importFile
function importFile($filename)
{
\Nette\Database\Helpers::loadFromFile($this->connection, $filename);
}