本文整理汇总了PHP中lithium\data\Connections::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Connections::config方法的具体用法?PHP Connections::config怎么用?PHP Connections::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\data\Connections
的用法示例。
在下文中一共展示了Connections::config方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStreamConnection
public function testStreamConnection()
{
$config = array('type' => 'Http', 'socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
Connections::add('stream-test', $config);
$result = Connections::get('stream-test');
$this->assertTrue($result instanceof Http);
Connections::config(array('stream-test' => false));
}
示例2: testAccessorMethods
/**
* Tests Collection accessors (getters/setters).
*/
public function testAccessorMethods()
{
Connections::config(array('mock-source' => array('type' => 'lithium\\tests\\mocks\\data\\MockSource')));
$model = $this->_model;
$model::config(array('connection' => false, 'key' => 'id'));
$collection = new DocumentSet(compact('model'));
$this->assertEqual($model, $collection->model());
$this->assertEqual(compact('model'), $collection->meta());
}
示例3: testStreamConnection
public function testStreamConnection()
{
$config = array('type' => 'Http', 'socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
Connections::add('stream-test', $config);
$result = Connections::get('stream-test');
$this->assertInstanceOf('lithium\\data\\source\\Http', $result);
Connections::config(array('stream-test' => false));
}
示例4: tearDown
public function tearDown()
{
Connections::reset();
Connections::config($this->_configs);
}
示例5: array
if (!empty($solution)) {
$default = array('id' => 'help-' . $checkName, 'title' => $checkName, 'content' => null);
if (is_array($solution['content'])) {
$solution['content'] = join("\n<br />", $solution['content']);
}
$solutions[$checkName] = $solution += $default;
}
return "<div class=\"test-result test-result-{$status}\">{$message}</div>";
};
$sanityChecks = array('resourcesWritable' => function () use($notify) {
if (is_writable($path = realpath(LITHIUM_APP_PATH . '/resources'))) {
return $notify(true, 'Resources directory is writable.');
}
return $notify(false, array("Your resource path (<code>{$path}</code>) is not writeable. " . "To fix this on *nix and Mac OSX, run the following from the command line:", "<code>chmod -R 0777 {$path}</code>"));
}, 'database' => function () use($notify) {
$config = Connections::config();
$boot = realpath(LITHIUM_APP_PATH . '/config/bootstrap.php');
$connections = realpath(LITHIUM_APP_PATH . '/config/bootstrap/connections.php');
if (empty($config)) {
return $notify('notice', array('No database connections defined.'), array('title' => 'Database Connections', 'content' => array('To create a database connection, edit the file <code>' . $boot . '</code>, ', 'and uncomment the following line:', '<pre><code>require __DIR__ . \'/bootstrap/connections.php\';</code></pre>', 'Then, edit the file <code>' . $connections . '</code>.')));
}
return $notify(true, 'Database connection(s) configured.');
}, 'magicQuotes' => function () use($notify) {
if (get_magic_quotes_gpc() === 0) {
return;
}
return $notify(false, array("Magic quotes are enabled in your PHP configuration. Please set <code>" . "magic_quotes_gpc = Off</code> in your <code>php.ini</code> settings."));
}, 'registerGlobals' => function () use($notify) {
if (!ini_get('register_globals')) {
return;
}
示例6: function
if (!ini_get('register_globals')) {
return;
}
return $notify('error', 'Register globals is enabled in your PHP configuration', 'Please set <code>register_globals = Off</code> in your <code>php.ini</code> settings.');
}, 'curlwrappers' => function () use($notify, $compiled) {
if (!$compiled('with-curlwrappers')) {
return;
}
return $notify('error', 'Curlwrappers are enabled, some things might not work as expected.', "This is an expiremental and usually broken feature of PHP.\n\t\t\tPlease recompile your PHP binary without using the <code>--with-curlwrappers</code>\n\t\t\tflag or use a precompiled binary that was compiled without the flag.");
}, 'shortOpenTag' => function () use($notify, $compiled) {
if (!ini_get('short_open_tag')) {
return;
}
return $notify('warning', 'Short open tags are enabled, you may want to disable them.', "It is recommended to not rely on this option being enabled.\n\t\t\tTo increase the portability of your code disable this option by setting\n\t\t\t<code>short_open_tag = Off</code> in your <code>php.ini</code>.");
}, 'database' => function () use($notify) {
if ($config = Connections::config()) {
return $notify('success', 'Database connection(s) configured');
}
return $notify('warning', 'No database connection defined', "To create a database connection:\n\t\t\t<ol>\n\t\t\t\t<li>Edit the file <code>config/bootstrap.php</code>.</li>\n\t\t\t\t<li>\n\t\t\t\t\tUncomment the line having\n\t\t\t\t\t<code>require __DIR__ . '/bootstrap/connections.php';</code>.\n\t\t\t\t</li>\n\t\t\t\t<li>Edit the file <code>config/bootstrap/connections.php</code>.</li>\n\t\t\t</ol>");
}, 'change' => function () use($notify, $self) {
$template = $self->html->link('template', 'http://li3.me/docs/lithium/template');
return $notify('warning', "You're using the application's default home page", "To change this {$template}, edit the file\n\t\t\t<code>views/pages/home.html.php</code>.\n\t\t\tTo change the layout,\n\t\t\t(that is what's wrapping content)\n\t\t\tedit the file <code>views/layouts/default.html.php</code>.");
}, 'dbSupport' => function () use($support) {
$paths = array('data.source', 'adapter.data.source.database', 'adapter.data.source.http');
$list = array();
foreach ($paths as $path) {
$list = array_merge($list, Libraries::locate($path, null, array('recursive' => false)));
}
$list = array_filter($list, function ($class) {
return method_exists($class, 'enabled');
});
示例7: testRelationshipGeneration
public function testRelationshipGeneration()
{
Connections::add('mock-source', $this->_testConfig);
$from = 'lithium\\tests\\mocks\\data\\MockComment';
$to = 'lithium\\tests\\mocks\\data\\MockPost';
$from::config(array('connection' => 'mock-source'));
$to::config(array('connection' => 'mock-source'));
$result = $this->db->relationship($from, 'belongsTo', 'MockPost');
$expected = compact('from', 'to') + array('name' => 'MockPost', 'type' => 'belongsTo', 'keys' => array('mockComment' => '_id'), 'link' => 'contained', 'conditions' => null, 'fields' => true, 'fieldName' => 'mockPost', 'init' => true);
$this->assertEqual($expected, $result->data());
Connections::config(array('mock-source' => false));
}
示例8: tearDown
public function tearDown()
{
Connections::config(array('mock-source' => false));
Connections::config($this->_configs);
}
示例9: tearDown
public function tearDown()
{
Connections::reset();
Connections::config($this->_backup['connections']);
}