/** * Construct a new model instance and connect it a database table's row. * Pass an id to immediately fetch model data from the database. If not id is given * a new persistent intance gets created wich got its id set as soon as it is stored * via a call to _store(). * * @param integer|Zend_Db_Table_Row $id (Optional) (Id of) Existing database row. * @param Zend_Db_Table_Abstract $tableGatewayModel (Optional) Opus_Db model to fetch table row from. * @throws Opus_Model_Exception Thrown if passed id is invalid. * @see Opus_Model_AbstractDb#__construct() */ public function __construct($id = null, Zend_Db_Table_Abstract $tableGatewayModel = null) { parent::__construct($id, $tableGatewayModel); if (false === is_null($this->_parentColumn) && $this->_parentColumn != '') { $parentId = $this->_primaryTableRow->{$this->_parentColumn}; if (false === is_null($parentId)) { $this->setParentId($parentId); } } }
/** * Override to allow retrieving an account either by id or by the unique login name. * If neither id nor login are specified a new persistant instance gets created which * got idts id set as soon as it is stored via a call to _store(). * * @param integer|Zend_Db_Table_Row $id (Optional) (Id of) Existing database row. * @param Zend_Db_Table_Abstract $tableGatewayModel (Optional) Opus_Db model to fetch table row from. * @param string $id (Optional) Login of existing record. * @throws Opus_Model_Exception Thrown if passed id is invalid or login and id are specified. */ public function __construct($id = null, Zend_Db_Table_Abstract $tableGatewayModel = null, $login = null) { if (false === is_null($login) && false === empty($login)) { if (false === is_null($id) && false === empty($id)) { throw new Opus_Model_Exception('Login and id of an account are specified, specify either id or login.'); } $id = Opus_Account::fetchAccountRowByLogin($login); if (!isset($id)) { throw new Opus_Security_Exception('An account with the login name ' . $login . ' cannot be found.'); } } parent::__construct($id, $tableGatewayModel); }