Example #1
0
 public function run()
 {
     Meshing_Utils::initialiseDb();
     $outFormat = '%-15s%-12s%-15s%-40s';
     $this->ruleOff($lineLength = 15 + 12 + 15 + 40);
     echo sprintf($outFormat, 'Name', 'Adaptor', 'User', 'Host') . "\n";
     $this->ruleOff($lineLength);
     $connections = P2PConnectionPeer::doSelect(new Criteria());
     /* @var $connection P2PConnection */
     foreach ($connections as $connection) {
         echo sprintf($outFormat, $connection->getName(), $connection->getAdaptor(), $connection->getUsername() ? $connection->getUsername() : 'n/a', $connection->getHost());
         echo "\n";
     }
 }
Example #2
0
 /**
  * Get XML version of default runtime file, returns temp version to convert to PHP
  */
 protected function createRuntimeXml($runTime, $newRunTime)
 {
     // Ensure the file exists
     if (!is_readable($runTime)) {
         throw new Exception("Can't load runtime configuration");
     }
     // Ensure the new file won't overwrite the old one!
     if ($runTime == $newRunTime) {
         throw new Exception('The new XML location must be different to the existing one');
     }
     // Load up the XML doc
     $xml = simplexml_load_file($runTime);
     // @todo Validate XML file
     // Grab the connections known to the system (@todo would we want more than 50!?)
     Meshing_Utils::initialiseDb();
     $c = new Criteria();
     $c->setLimit(50);
     $connections = P2PConnectionPeer::doSelect($c);
     // Add each connection in as a datasource
     /* @var $connection P2PConnection */
     foreach ($connections as $connection) {
         // Modify XML document
         $element = $xml->propel->datasources->addChild('datasource');
         $element['id'] = $connection->getName();
         $inner1 = $element->addChild('adapter', $connection->getAdaptor());
         $inner2 = $element->addChild('connection');
         $inner2->addChild('dsn', $connection->getCalculatedDsn());
         $inner2->addChild('user', $connection->getUsername());
         $inner2->addChild('password', $connection->getPassword());
     }
     // Write out modified XML doc to new file
     $xml->asXml($newRunTime);
 }
Example #3
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(P2PConnectionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(P2PConnectionPeer::DATABASE_NAME);
         $criteria->add(P2PConnectionPeer::ID, $pks, Criteria::IN);
         $objs = P2PConnectionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }