/** * Returns a new P2PConnectionQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return P2PConnectionQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof P2PConnectionQuery) { return $criteria; } $query = new P2PConnectionQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
public function preRunCheck() { if (!$this->opts->name) { throw new Zend_Console_Getopt_Exception('The node must have a name (use --name)'); } if (!$this->opts->connection) { throw new Zend_Console_Getopt_Exception('The node must have a connection (use --connection)'); } if (!$this->opts->schema) { throw new Zend_Console_Getopt_Exception('The node must have a schema (use --schema)'); } // Check that the name supplied is unique Meshing_Utils::initialiseDb(); $node = P2POwnNodeQuery::create()->findOneByName($this->opts->name); if ($node) { throw new Zend_Console_Getopt_Exception('A node of that name already exists'); } // Check that the connection exists $this->connection = P2PConnectionQuery::create()->findOneByName($this->opts->connection); if (!$this->connection) { throw new Zend_Console_Getopt_Exception('The specified connection is not registered'); } // Check that the schema exists $this->schema = MeshingSchemaQuery::create()->findOneByName($this->opts->schema); if (!$this->schema) { throw new Zend_Console_Getopt_Exception('The specified schema is not registered'); } }
public function preRunCheck() { $name = $this->opts->name; if (!$name) { throw new Zend_Console_Getopt_Exception('The connection name must be specified.'); } // @todo Check that this connection isn't in use Meshing_Utils::initialiseDb(); $this->connection = P2PConnectionQuery::create()->findOneByName($name); if (!$this->connection) { throw new Zend_Console_Getopt_Exception('No such connection.'); } }
/** * Get the associated P2PConnection object * * @param PropelPDO Optional Connection object. * @return P2PConnection The associated P2PConnection object. * @throws PropelException */ public function getP2PConnection(PropelPDO $con = null) { if ($this->aP2PConnection === null && $this->connection_id !== null) { $this->aP2PConnection = P2PConnectionQuery::create()->findPk($this->connection_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aP2PConnection->addP2POwnNodes($this); */ } return $this->aP2PConnection; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(P2PConnectionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $ret = $this->preDelete($con); if ($ret) { P2PConnectionQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (PropelException $e) { $con->rollBack(); throw $e; } }
protected function connectionExists($name) { return (bool) P2PConnectionQuery::create()->findOneByName($name); }