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); }
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())); }
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); }