addConnections() public static method

Add connections Shanty Mongo
public static addConnections ( array $options )
$options array
示例#1
0
 public function preDispatch()
 {
     $this->_helper->layout->setLayout('live');
     // Initialize mongodb
     $db = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application-cli.ini', 'mongodb');
     Shanty_Mongo::addConnections($db);
 }
示例#2
0
 public function testAddConnectionsMultipleGroups()
 {
     $connections = array('users' => array('host' => 'localhost'), 'accounts' => array('masters' => array(0 => array('host' => '127.0.0.1'), 1 => array('host' => 'localhost')), 'slaves' => array(0 => array('host' => '127.0.0.1'), 1 => array('host' => 'localhost'))));
     Shanty_Mongo::addConnections($connections);
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroups()));
     $this->assertEquals(1, count(Shanty_Mongo::getConnectionGroup('users')->getMasters()));
     $this->assertEquals(0, count(Shanty_Mongo::getConnectionGroup('users')->getSlaves()));
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroup('accounts')->getMasters()));
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroup('accounts')->getSlaves()));
     Shanty_Mongo::removeConnectionGroups();
     $this->assertEquals(0, count(Shanty_Mongo::getConnectionGroups()));
     Shanty_Mongo::addConnections(new Zend_Config($connections));
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroups()));
     $this->assertEquals(1, count(Shanty_Mongo::getConnectionGroup('users')->getMasters()));
     $this->assertEquals(0, count(Shanty_Mongo::getConnectionGroup('users')->getSlaves()));
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroup('accounts')->getMasters()));
     $this->assertEquals(2, count(Shanty_Mongo::getConnectionGroup('accounts')->getSlaves()));
 }
示例#3
0
 public function referralAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $db = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application-cli.ini', 'mongodb');
     Shanty_Mongo::addConnections($db);
     $ref = App_Model_Mongodb_RequestLog::referral();
     print_r($ref);
 }