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


PHP Connections::get方法代码示例

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


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

示例1: check

 /**
  * Check request reCAPTCHA validity
  * This method return `true` or `false` after validation, and set error in
  * helper. If `true` error is set to null, otherwise `'incorrect-captcha-sol'`
  * 
  * Example:
  * {{{
  *		class YourController extends \lithium\action\Controller {
  *			public function index() {
  *				if ($this->request->data) {
  *					if (!Recaptcha::check($this->request)) {
  *						return;
  *					}
  *				}
  *			}
  *		}
  * }}}
  * @param object $request Pass request object to check method
  * @return boolean
  * @throws ConfigException
  * @throws RuntimeException 
  */
 public static function check(\lithium\net\http\Request $request)
 {
     $config = Libraries::get('li3_recaptcha', 'keys');
     if (!$config['private']) {
         throw new ConfigException('To use reCAPTCHA you must get API key from' . 'https://www.google.com/recaptcha/admin/create');
     }
     if (!$request->env('SERVER_ADDR')) {
         throw new RuntimeException('For security reasons, you must pass the remote ip to reCAPTCHA');
     }
     $data = array('privatekey' => $config['private'], 'remoteip' => $request->env('SERVER_ADDR'), 'challenge' => null, 'response' => null);
     if ($request->data) {
         $data['challenge'] = $request->data['recaptcha_challenge_field'];
         $data['response'] = $request->data['recaptcha_response_field'];
     }
     if (!$data['challenge'] || !$data['response']) {
         RecaptchaHelper::$error = 'incorrect-captcha-sol';
         return false;
     }
     $service = Connections::get('recaptcha');
     $serviceRespond = explode("\n", $service->post('/recaptcha/api/verify', $data));
     if ($serviceRespond[0] == 'true') {
         RecaptchaHelper::$error = null;
         return true;
     } else {
         RecaptchaHelper::$error = 'incorrect-captcha-sol';
         return false;
     }
 }
开发者ID:djordje,项目名称:li3_recaptcha,代码行数:50,代码来源:Recaptcha.php

示例2: skip

 /**
  * Skip the test if a Sqlite adapter configuration is unavailable.
  *
  * @return void
  * @todo Tie into the Environment class to ensure that the test database is being used.
  */
 public function skip()
 {
     $this->_dbConfig = Connections::get('sqlite3', array('config' => true));
     $hasDb = isset($this->_dbConfig['adapter']) && $this->_dbConfig['adapter'] == 'Sqlite3';
     $message = 'Test database is either unavailable, or not using a Sqlite adapter';
     $this->skipIf(!$hasDb, $message);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:13,代码来源:Sqlite3Test.php

示例3: skip

 /**
  * Skip the test if no `test` CouchDb connection available.
  *
  * @return void
  */
 public function skip()
 {
     $isAvailable = Connections::get('test', array('config' => true)) && Connections::get('test')->isConnected(array('autoConnect' => true));
     $this->skipIf(!$isAvailable, "No test connection available");
     $couchConnection = strpos(get_class(Connections::get('test')), 'CouchDb');
     $this->skipIf(!$couchConnection, "Test connection is not CouchDb");
 }
开发者ID:EHER,项目名称:chegamos,代码行数:12,代码来源:CouchDbIntegrationTest.php

示例4: skip

	public function skip() {
		$isAvailable = (
			Connections::get('test', array('config' => true)) &&
			Connections::get('test')->isConnected(array('autoConnect' => true))
		);
		$this->skipIf(!$isAvailable, "No test connection available");
	}
开发者ID:niel,项目名称:lithium,代码行数:7,代码来源:FieldsTest.php

示例5: testBasicGet

 public function testBasicGet()
 {
     $topsy = Connections::get('test-topsy');
     $headers = array('Content-Type' => 'application/json');
     $results = json_decode($topsy->connection->get('authorinfo.json?url=http://twitter.com/mehlah', array(), compact('headers')));
     $this->assertEqual('Mehdi Lahmam B.', $results->response->name);
 }
开发者ID:mehlah,项目名称:li3_topsy,代码行数:7,代码来源:TopsyTest.php

示例6: testStreamConnection

 public function testStreamConnection()
 {
     $config = array('socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
     Connections::add('stream-test', 'Http', $config);
     $result = Connections::get('stream-test');
     $this->assertTrue($result instanceof \lithium\data\source\Http);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:7,代码来源:ConnectionsTest.php

示例7: __init

 public static function __init(array $options = array())
 {
     parent::__init($options);
     $self = static::_instance();
     $self->_finders['count'] = function ($self, $params, $chain) use(&$query, &$classes) {
         $db = Connections::get($self::meta('connection'));
         $records = $db->read('SELECT count(*) as count FROM posts', array('return' => 'array'));
         return $records[0]['count'];
     };
     Post::applyFilter('save', function ($self, $params, $chain) {
         $post = $params['record'];
         if (!$post->id) {
             $post->created = date('Y-m-d H:i:s');
         } else {
             $post->modified = date('Y-m-d H:i:s');
         }
         $params['record'] = $post;
         return $chain->next($self, $params, $chain);
     });
     Validator::add('isUniqueTitle', function ($value, $format, $options) {
         $conditions = array('title' => $value);
         // If editing the post, skip the current psot
         if (isset($options['values']['id'])) {
             $conditions[] = 'id != ' . $options['values']['id'];
         }
         // Lookup for posts with same title
         return !Post::find('first', array('conditions' => $conditions));
     });
 }
开发者ID:adityamooley,项目名称:Lithium-Blog-Tutorial,代码行数:29,代码来源:Post.php

示例8: tearDown

 public function tearDown()
 {
     $connection = Connections::get('default');
     $mongo = $connection->connection;
     foreach ($mongo->listCollections() as $collection) {
         $collection->drop();
     }
 }
开发者ID:blainesch,项目名称:li3_fake_model,代码行数:8,代码来源:ModelTest.php

示例9: skip

 /**
  * Skip the test if no test database connection available.
  */
 public function skip()
 {
     $dbConfig = Connections::get($this->_connection, ['config' => true]);
     $isAvailable = $dbConfig && Connections::get($this->_connection)->isConnected(['autoConnect' => true]);
     $this->skipIf(!$isAvailable, "No {$this->_connection} connection available.");
     $db = Connections::get($this->_connection);
     $this->skipIf(!$db instanceof Database, "The {$this->_connection} connection is not a relational database.");
 }
开发者ID:jails,项目名称:li3_access,代码行数:11,代码来源:AclNodeTest.php

示例10: skip

 /**
  * Skip the test if a MySQL adapter configuration is unavailable.
  *
  * @return void
  * @todo Tie into the Environment class to ensure that the test database is being used.
  */
 public function skip()
 {
     $this->skipIf(!MySql::enabled(), 'MySQL Extension is not loaded');
     $this->_dbConfig = Connections::get('test', array('config' => true));
     $hasDb = isset($this->_dbConfig['adapter']) && $this->_dbConfig['adapter'] == 'MySql';
     $message = 'Test database is either unavailable, or not using a MySQL adapter';
     $this->skipIf(!$hasDb, $message);
 }
开发者ID:EHER,项目名称:monopolis,代码行数:14,代码来源:MySqlTest.php

示例11: setUp

 /**
  * Setup method run before every test method.
  */
 public function setUp()
 {
     if (empty($this->_backup)) {
         foreach (Connections::get() as $conn) {
             $this->_backup[$conn] = Connections::get($conn, array('config' => true));
         }
     }
     Connections::reset();
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:12,代码来源:CollectionTest.php

示例12: connect

 public function connect($connection, $options = array())
 {
     $options += array('autoConnect' => true);
     $this->_dbConfig = Connections::get($connection, array('config' => true));
     $db = $this->_db = Connections::get($connection);
     $this->skipIf(!$db, "The `{$connection}` connection is not correctly configured.");
     $this->skipIf(!$db::enabled(), 'Extension is not loaded.');
     $this->skipIf(!$db->isConnected($options), "No `{$connection}` connection available.");
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:9,代码来源:Base.php

示例13: skip

 public function skip()
 {
     $connection = $this->_connection;
     $this->_dbConfig = Connections::get($this->_connection, array('config' => true));
     $this->skipIf(!$this->with(array('Sqlite3')));
     $this->_db = new MockSqlite3($this->_dbConfig);
     $isConnected = $this->_db->isConnected(array('autoConnect' => true));
     $this->skipIf(!$isConnected, "No {$connection} connection available.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:9,代码来源:Sqlite3SchemaTest.php

示例14: testIssuesRead

 public function testIssuesRead()
 {
     $gh = Connections::get('test-gh');
     $query = new Query(array('model' => $this->_models['issues']));
     $results = $gh->read($query);
     $expected = 'octocat';
     $result = $results->first();
     $this->assertEqual($expected, $result->user->login);
 }
开发者ID:notomato,项目名称:li3_github,代码行数:9,代码来源:GitHubTest.php

示例15: skip

 public function skip()
 {
     $connection = 'lithium_mysql_test';
     $this->_dbConfig = Connections::get($connection, array('config' => true));
     $isAvailable = $this->_dbConfig && Connections::get($connection)->isConnected(array('autoConnect' => true));
     $this->skipIf(!$isAvailable, "No {$connection} connection available.");
     $this->db = Connections::get($connection);
     $this->skipIf(!$this->db instanceof Database, "The {$connection} connection is not a relational database.");
 }
开发者ID:rmarscher,项目名称:lithium,代码行数:9,代码来源:FieldsTest.php


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