Author: hsanchez Date: 2007-04-18 13:39:28 -0300 (Wed, 18 Apr 2007) New Revision: 4555 Added: prosistem/alba/trunk/alba/lib/model/RolResponsable.php prosistem/alba/trunk/alba/lib/model/RolResponsablePeer.php prosistem/alba/trunk/alba/lib/model/map/RolResponsableMapBuilder.php prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsable.php prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsablePeer.php Removed: prosistem/alba/trunk/alba/lib/model/Roles.php prosistem/alba/trunk/alba/lib/model/RolesPeer.php prosistem/alba/trunk/alba/lib/model/map/RolesMapBuilder.php prosistem/alba/trunk/alba/lib/model/om/BaseRoles.php prosistem/alba/trunk/alba/lib/model/om/BaseRolesPeer.php Modified: prosistem/alba/trunk/alba/config/schema.xml Log: Cambiando la tabla roles por rol_responsable Modified: prosistem/alba/trunk/alba/config/schema.xml =================================================================== --- prosistem/alba/trunk/alba/config/schema.xml 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/config/schema.xml 2007-04-18 16:39:28 UTC (rev 4555) @@ -723,7 +723,7 @@ <column name="grupo" type="varchar" size="30" required="false" default=""/> <column name="defecto" type="boolean" required="true" default="0"/> </table> - <table name="roles" idMethod="native"> + <table name="rol_responsable" idMethod="native"> <column name="id" type="INTEGER" required="true" autoIncrement="true" primaryKey="true"/> <column name="nombre" type="VARCHAR" size="128" required="true" default=""/> <column name="descripcion" type="VARCHAR" size="255" default=""/> Added: prosistem/alba/trunk/alba/lib/model/RolResponsable.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/RolResponsable.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/RolResponsable.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -0,0 +1,12 @@ +<?php + +/** + * Subclass for representing a row from the 'rol_responsable' table. + * + * + * + * @package lib.model + */ +class RolResponsable extends BaseRolResponsable +{ +} Property changes on: prosistem/alba/trunk/alba/lib/model/RolResponsable.php ___________________________________________________________________ Name: svn:keywords + Id Date Author Rev URL Added: prosistem/alba/trunk/alba/lib/model/RolResponsablePeer.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/RolResponsablePeer.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/RolResponsablePeer.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -0,0 +1,12 @@ +<?php + +/** + * Subclass for performing query and update operations on the 'rol_responsable' table. + * + * + * + * @package lib.model + */ +class RolResponsablePeer extends BaseRolResponsablePeer +{ +} Property changes on: prosistem/alba/trunk/alba/lib/model/RolResponsablePeer.php ___________________________________________________________________ Name: svn:keywords + Id Date Author Rev URL Deleted: prosistem/alba/trunk/alba/lib/model/Roles.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/Roles.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/Roles.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -1,12 +0,0 @@ -<?php - -/** - * Subclass for representing a row from the 'roles' table. - * - * - * - * @package lib.model - */ -class Roles extends BaseRoles -{ -} Deleted: prosistem/alba/trunk/alba/lib/model/RolesPeer.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/RolesPeer.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/RolesPeer.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -1,12 +0,0 @@ -<?php - -/** - * Subclass for performing query and update operations on the 'roles' table. - * - * - * - * @package lib.model - */ -class RolesPeer extends BaseRolesPeer -{ -} Added: prosistem/alba/trunk/alba/lib/model/map/RolResponsableMapBuilder.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/map/RolResponsableMapBuilder.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/map/RolResponsableMapBuilder.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -0,0 +1,44 @@ +<?php + + + +class RolResponsableMapBuilder { + + + const CLASS_NAME = 'lib.model.map.RolResponsableMapBuilder'; + + + private $dbMap; + + + public function isBuilt() + { + return ($this->dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('alba'); + + $tMap = $this->dbMap->addTable('rol_responsable'); + $tMap->setPhpName('RolResponsable'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, true, 128); + + $tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('ACTIVO', 'Activo', 'boolean', CreoleTypes::BOOLEAN, true); + + } +} \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/lib/model/map/RolResponsableMapBuilder.php ___________________________________________________________________ Name: svn:keywords + Id Date Author Rev URL Deleted: prosistem/alba/trunk/alba/lib/model/map/RolesMapBuilder.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/map/RolesMapBuilder.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/map/RolesMapBuilder.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -1,44 +0,0 @@ -<?php - - - -class RolesMapBuilder { - - - const CLASS_NAME = 'lib.model.map.RolesMapBuilder'; - - - private $dbMap; - - - public function isBuilt() - { - return ($this->dbMap !== null); - } - - - public function getDatabaseMap() - { - return $this->dbMap; - } - - - public function doBuild() - { - $this->dbMap = Propel::getDatabaseMap('alba'); - - $tMap = $this->dbMap->addTable('roles'); - $tMap->setPhpName('Roles'); - - $tMap->setUseIdGenerator(true); - - $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); - - $tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, true, 128); - - $tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::VARCHAR, false, 255); - - $tMap->addColumn('ACTIVO', 'Activo', 'boolean', CreoleTypes::BOOLEAN, true); - - } -} \ No newline at end of file Added: prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsable.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsable.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsable.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -0,0 +1,379 @@ +<?php + + +abstract class BaseRolResponsable extends BaseObject implements Persistent { + + + + protected static $peer; + + + + protected $id; + + + + protected $nombre = ''; + + + + protected $descripcion = ''; + + + + protected $activo = true; + + + protected $alreadyInSave = false; + + + protected $alreadyInValidation = false; + + + public function getId() + { + + return $this->id; + } + + + public function getNombre() + { + + return $this->nombre; + } + + + public function getDescripcion() + { + + return $this->descripcion; + } + + + public function getActivo() + { + + return $this->activo; + } + + + public function setId($v) + { + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = RolResponsablePeer::ID; + } + + } + + public function setNombre($v) + { + + if ($this->nombre !== $v || $v === '') { + $this->nombre = $v; + $this->modifiedColumns[] = RolResponsablePeer::NOMBRE; + } + + } + + public function setDescripcion($v) + { + + if ($this->descripcion !== $v || $v === '') { + $this->descripcion = $v; + $this->modifiedColumns[] = RolResponsablePeer::DESCRIPCION; + } + + } + + public function setActivo($v) + { + + if ($this->activo !== $v || $v === true) { + $this->activo = $v; + $this->modifiedColumns[] = RolResponsablePeer::ACTIVO; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->nombre = $rs->getString($startcol + 1); + + $this->descripcion = $rs->getString($startcol + 2); + + $this->activo = $rs->getBoolean($startcol + 3); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 4; + } catch (Exception $e) { + throw new PropelException("Error populating RolResponsable object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RolResponsablePeer::DATABASE_NAME); + } + + try { + $con->begin(); + RolResponsablePeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RolResponsablePeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = RolResponsablePeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += RolResponsablePeer::doUpdate($this, $con); + } + $this->resetModified(); } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = RolResponsablePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = RolResponsablePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getNombre(); + break; + case 2: + return $this->getDescripcion(); + break; + case 3: + return $this->getActivo(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolResponsablePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getNombre(), + $keys[2] => $this->getDescripcion(), + $keys[3] => $this->getActivo(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = RolResponsablePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setNombre($value); + break; + case 2: + $this->setDescripcion($value); + break; + case 3: + $this->setActivo($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolResponsablePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDescripcion($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setActivo($arr[$keys[3]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(RolResponsablePeer::DATABASE_NAME); + + if ($this->isColumnModified(RolResponsablePeer::ID)) $criteria->add(RolResponsablePeer::ID, $this->id); + if ($this->isColumnModified(RolResponsablePeer::NOMBRE)) $criteria->add(RolResponsablePeer::NOMBRE, $this->nombre); + if ($this->isColumnModified(RolResponsablePeer::DESCRIPCION)) $criteria->add(RolResponsablePeer::DESCRIPCION, $this->descripcion); + if ($this->isColumnModified(RolResponsablePeer::ACTIVO)) $criteria->add(RolResponsablePeer::ACTIVO, $this->activo); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(RolResponsablePeer::DATABASE_NAME); + + $criteria->add(RolResponsablePeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setNombre($this->nombre); + + $copyObj->setDescripcion($this->descripcion); + + $copyObj->setActivo($this->activo); + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new RolResponsablePeer(); + } + return self::$peer; + } + +} \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsable.php ___________________________________________________________________ Name: svn:keywords + Id Date Author Rev URL Added: prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsablePeer.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsablePeer.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsablePeer.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -0,0 +1,378 @@ +<?php + + +abstract class BaseRolResponsablePeer { + + + const DATABASE_NAME = 'alba'; + + + const TABLE_NAME = 'rol_responsable'; + + + const CLASS_DEFAULT = 'lib.model.RolResponsable'; + + + const NUM_COLUMNS = 4; + + + const NUM_LAZY_LOAD_COLUMNS = 0; + + + + const ID = 'rol_responsable.ID'; + + + const NOMBRE = 'rol_responsable.NOMBRE'; + + + const DESCRIPCION = 'rol_responsable.DESCRIPCION'; + + + const ACTIVO = 'rol_responsable.ACTIVO'; + + + private static $phpNameMap = null; + + + + private static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('Id', 'Nombre', 'Descripcion', 'Activo', ), + BasePeer::TYPE_COLNAME => array (RolResponsablePeer::ID, RolResponsablePeer::NOMBRE, RolResponsablePeer::DESCRIPCION, RolResponsablePeer::ACTIVO, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'nombre', 'descripcion', 'activo', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nombre' => 1, 'Descripcion' => 2, 'Activo' => 3, ), + BasePeer::TYPE_COLNAME => array (RolResponsablePeer::ID => 0, RolResponsablePeer::NOMBRE => 1, RolResponsablePeer::DESCRIPCION => 2, RolResponsablePeer::ACTIVO => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nombre' => 1, 'descripcion' => 2, 'activo' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/RolResponsableMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.RolResponsableMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = RolResponsablePeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(RolResponsablePeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(RolResponsablePeer::ID); + + $criteria->addSelectColumn(RolResponsablePeer::NOMBRE); + + $criteria->addSelectColumn(RolResponsablePeer::DESCRIPCION); + + $criteria->addSelectColumn(RolResponsablePeer::ACTIVO); + + } + + const COUNT = 'COUNT(rol_responsable.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT rol_responsable.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RolResponsablePeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RolResponsablePeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = RolResponsablePeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = RolResponsablePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return RolResponsablePeer::populateObjects(RolResponsablePeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + RolResponsablePeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = RolResponsablePeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return RolResponsablePeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(RolResponsablePeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(RolResponsablePeer::ID); + $selectCriteria->add(RolResponsablePeer::ID, $criteria->remove(RolResponsablePeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(RolResponsablePeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(RolResponsablePeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof RolResponsable) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(RolResponsablePeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doValidate(RolResponsable $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(RolResponsablePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(RolResponsablePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(RolResponsablePeer::DATABASE_NAME, RolResponsablePeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = RolResponsablePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(RolResponsablePeer::DATABASE_NAME); + + $criteria->add(RolResponsablePeer::ID, $pk); + + + $v = RolResponsablePeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(RolResponsablePeer::ID, $pks, Criteria::IN); + $objs = RolResponsablePeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseRolResponsablePeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/RolResponsableMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.RolResponsableMapBuilder'); +} Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseRolResponsablePeer.php ___________________________________________________________________ Name: svn:keywords + Id Date Author Rev URL Deleted: prosistem/alba/trunk/alba/lib/model/om/BaseRoles.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/om/BaseRoles.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/om/BaseRoles.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -1,379 +0,0 @@ -<?php - - -abstract class BaseRoles extends BaseObject implements Persistent { - - - - protected static $peer; - - - - protected $id; - - - - protected $nombre = ''; - - - - protected $descripcion = ''; - - - - protected $activo = true; - - - protected $alreadyInSave = false; - - - protected $alreadyInValidation = false; - - - public function getId() - { - - return $this->id; - } - - - public function getNombre() - { - - return $this->nombre; - } - - - public function getDescripcion() - { - - return $this->descripcion; - } - - - public function getActivo() - { - - return $this->activo; - } - - - public function setId($v) - { - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = RolesPeer::ID; - } - - } - - public function setNombre($v) - { - - if ($this->nombre !== $v || $v === '') { - $this->nombre = $v; - $this->modifiedColumns[] = RolesPeer::NOMBRE; - } - - } - - public function setDescripcion($v) - { - - if ($this->descripcion !== $v || $v === '') { - $this->descripcion = $v; - $this->modifiedColumns[] = RolesPeer::DESCRIPCION; - } - - } - - public function setActivo($v) - { - - if ($this->activo !== $v || $v === true) { - $this->activo = $v; - $this->modifiedColumns[] = RolesPeer::ACTIVO; - } - - } - - public function hydrate(ResultSet $rs, $startcol = 1) - { - try { - - $this->id = $rs->getInt($startcol + 0); - - $this->nombre = $rs->getString($startcol + 1); - - $this->descripcion = $rs->getString($startcol + 2); - - $this->activo = $rs->getBoolean($startcol + 3); - - $this->resetModified(); - - $this->setNew(false); - - return $startcol + 4; - } catch (Exception $e) { - throw new PropelException("Error populating Roles object", $e); - } - } - - - public function delete($con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(RolesPeer::DATABASE_NAME); - } - - try { - $con->begin(); - RolesPeer::doDelete($this, $con); - $this->setDeleted(true); - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - - public function save($con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(RolesPeer::DATABASE_NAME); - } - - try { - $con->begin(); - $affectedRows = $this->doSave($con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - - protected function doSave($con) - { - $affectedRows = 0; if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - - if ($this->isModified()) { - if ($this->isNew()) { - $pk = RolesPeer::doInsert($this, $con); - $affectedRows += 1; - $this->setId($pk); - $this->setNew(false); - } else { - $affectedRows += RolesPeer::doUpdate($this, $con); - } - $this->resetModified(); } - - $this->alreadyInSave = false; - } - return $affectedRows; - } - - protected $validationFailures = array(); - - - public function getValidationFailures() - { - return $this->validationFailures; - } - - - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = RolesPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = RolesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - return $this->getByPosition($pos); - } - - - public function getByPosition($pos) - { - switch($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getNombre(); - break; - case 2: - return $this->getDescripcion(); - break; - case 3: - return $this->getActivo(); - break; - default: - return null; - break; - } } - - - public function toArray($keyType = BasePeer::TYPE_PHPNAME) - { - $keys = RolesPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getNombre(), - $keys[2] => $this->getDescripcion(), - $keys[3] => $this->getActivo(), - ); - return $result; - } - - - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = RolesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - return $this->setByPosition($pos, $value); - } - - - public function setByPosition($pos, $value) - { - switch($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setNombre($value); - break; - case 2: - $this->setDescripcion($value); - break; - case 3: - $this->setActivo($value); - break; - } } - - - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = RolesPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDescripcion($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setActivo($arr[$keys[3]]); - } - - - public function buildCriteria() - { - $criteria = new Criteria(RolesPeer::DATABASE_NAME); - - if ($this->isColumnModified(RolesPeer::ID)) $criteria->add(RolesPeer::ID, $this->id); - if ($this->isColumnModified(RolesPeer::NOMBRE)) $criteria->add(RolesPeer::NOMBRE, $this->nombre); - if ($this->isColumnModified(RolesPeer::DESCRIPCION)) $criteria->add(RolesPeer::DESCRIPCION, $this->descripcion); - if ($this->isColumnModified(RolesPeer::ACTIVO)) $criteria->add(RolesPeer::ACTIVO, $this->activo); - - return $criteria; - } - - - public function buildPkeyCriteria() - { - $criteria = new Criteria(RolesPeer::DATABASE_NAME); - - $criteria->add(RolesPeer::ID, $this->id); - - return $criteria; - } - - - public function getPrimaryKey() - { - return $this->getId(); - } - - - public function setPrimaryKey($key) - { - $this->setId($key); - } - - - public function copyInto($copyObj, $deepCopy = false) - { - - $copyObj->setNombre($this->nombre); - - $copyObj->setDescripcion($this->descripcion); - - $copyObj->setActivo($this->activo); - - - $copyObj->setNew(true); - - $copyObj->setId(NULL); - } - - - public function copy($deepCopy = false) - { - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - return $copyObj; - } - - - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new RolesPeer(); - } - return self::$peer; - } - -} \ No newline at end of file Deleted: prosistem/alba/trunk/alba/lib/model/om/BaseRolesPeer.php =================================================================== --- prosistem/alba/trunk/alba/lib/model/om/BaseRolesPeer.php 2007-04-18 16:26:28 UTC (rev 4554) +++ prosistem/alba/trunk/alba/lib/model/om/BaseRolesPeer.php 2007-04-18 16:39:28 UTC (rev 4555) @@ -1,378 +0,0 @@ -<?php - - -abstract class BaseRolesPeer { - - - const DATABASE_NAME = 'alba'; - - - const TABLE_NAME = 'roles'; - - - const CLASS_DEFAULT = 'lib.model.Roles'; - - - const NUM_COLUMNS = 4; - - - const NUM_LAZY_LOAD_COLUMNS = 0; - - - - const ID = 'roles.ID'; - - - const NOMBRE = 'roles.NOMBRE'; - - - const DESCRIPCION = 'roles.DESCRIPCION'; - - - const ACTIVO = 'roles.ACTIVO'; - - - private static $phpNameMap = null; - - - - private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Nombre', 'Descripcion', 'Activo', ), - BasePeer::TYPE_COLNAME => array (RolesPeer::ID, RolesPeer::NOMBRE, RolesPeer::DESCRIPCION, RolesPeer::ACTIVO, ), - BasePeer::TYPE_FIELDNAME => array ('id', 'nombre', 'descripcion', 'activo', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - - private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nombre' => 1, 'Descripcion' => 2, 'Activo' => 3, ), - BasePeer::TYPE_COLNAME => array (RolesPeer::ID => 0, RolesPeer::NOMBRE => 1, RolesPeer::DESCRIPCION => 2, RolesPeer::ACTIVO => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nombre' => 1, 'descripcion' => 2, 'activo' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - - public static function getMapBuilder() - { - include_once 'lib/model/map/RolesMapBuilder.php'; - return BasePeer::getMapBuilder('lib.model.map.RolesMapBuilder'); - } - - public static function getPhpNameMap() - { - if (self::$phpNameMap === null) { - $map = RolesPeer::getTableMap(); - $columns = $map->getColumns(); - $nameMap = array(); - foreach ($columns as $column) { - $nameMap[$column->getPhpName()] = $column->getColumnName(); - } - self::$phpNameMap = $nameMap; - } - return self::$phpNameMap; - } - - static public function translateFieldName($name, $fromType, $toType) - { - $toNames = self::getFieldNames($toType); - $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); - } - return $toNames[$key]; - } - - - - static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, self::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); - } - return self::$fieldNames[$type]; - } - - - public static function alias($alias, $column) - { - return str_replace(RolesPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - - public static function addSelectColumns(Criteria $criteria) - { - - $criteria->addSelectColumn(RolesPeer::ID); - - $criteria->addSelectColumn(RolesPeer::NOMBRE); - - $criteria->addSelectColumn(RolesPeer::DESCRIPCION); - - $criteria->addSelectColumn(RolesPeer::ACTIVO); - - } - - const COUNT = 'COUNT(roles.ID)'; - const COUNT_DISTINCT = 'COUNT(DISTINCT roles.ID)'; - - - public static function doCount(Criteria $criteria, $distinct = false, $con = null) - { - $criteria = clone $criteria; - - $criteria->clearSelectColumns()->clearOrderByColumns(); - if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->addSelectColumn(RolesPeer::COUNT_DISTINCT); - } else { - $criteria->addSelectColumn(RolesPeer::COUNT); - } - - foreach($criteria->getGroupByColumns() as $column) - { - $criteria->addSelectColumn($column); - } - - $rs = RolesPeer::doSelectRS($criteria, $con); - if ($rs->next()) { - return $rs->getInt(1); - } else { - return 0; - } - } - - public static function doSelectOne(Criteria $criteria, $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = RolesPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - return null; - } - - public static function doSelect(Criteria $criteria, $con = null) - { - return RolesPeer::populateObjects(RolesPeer::doSelectRS($criteria, $con)); - } - - public static function doSelectRS(Criteria $criteria, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - if (!$criteria->getSelectColumns()) { - $criteria = clone $criteria; - RolesPeer::addSelectColumns($criteria); - } - - $criteria->setDbName(self::DATABASE_NAME); - - return BasePeer::doSelect($criteria, $con); - } - - public static function populateObjects(ResultSet $rs) - { - $results = array(); - - $cls = RolesPeer::getOMClass(); - $cls = Propel::import($cls); - while($rs->next()) { - - $obj = new $cls(); - $obj->hydrate($rs); - $results[] = $obj; - - } - return $results; - } - - public static function getTableMap() - { - return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); - } - - - public static function getOMClass() - { - return RolesPeer::CLASS_DEFAULT; - } - - - public static function doInsert($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; } else { - $criteria = $values->buildCriteria(); } - - $criteria->remove(RolesPeer::ID); - - $criteria->setDbName(self::DATABASE_NAME); - - try { - $con->begin(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch(PropelException $e) { - $con->rollback(); - throw $e; - } - - return $pk; - } - - - public static function doUpdate($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; - $comparison = $criteria->getComparison(RolesPeer::ID); - $selectCriteria->add(RolesPeer::ID, $criteria->remove(RolesPeer::ID), $comparison); - - } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } - - $criteria->setDbName(self::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - - public static function doDeleteAll($con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - $affectedRows = 0; try { - $con->begin(); - $affectedRows += BasePeer::doDeleteAll(RolesPeer::TABLE_NAME, $con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - - public static function doDelete($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RolesPeer::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; } elseif ($values instanceof Roles) { - - $criteria = $values->buildPkeyCriteria(); - } else { - $criteria = new Criteria(self::DATABASE_NAME); - $criteria->add(RolesPeer::ID, (array) $values, Criteria::IN); - } - - $criteria->setDbName(self::DATABASE_NAME); - - $affectedRows = 0; - try { - $con->begin(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - - public static function doValidate(Roles $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(RolesPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(RolesPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach($cols as $colName) { - if ($tableMap->containsColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - $res = BasePeer::doValidate(RolesPeer::DATABASE_NAME, RolesPeer::TABLE_NAME, $columns); - if ($res !== true) { - $request = sfContext::getInstance()->getRequest(); - foreach ($res as $failed) { - $col = RolesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); - $request->setError($col, $failed->getMessage()); - } - } - - return $res; - } - - - public static function retrieveByPK($pk, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - $criteria = new Criteria(RolesPeer::DATABASE_NAME); - - $criteria->add(RolesPeer::ID, $pk); - - - $v = RolesPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - - public static function retrieveByPKs($pks, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(); - $criteria->add(RolesPeer::ID, $pks, Criteria::IN); - $objs = RolesPeer::doSelect($criteria, $con); - } - return $objs; - } - -} -if (Propel::isInit()) { - try { - BaseRolesPeer::getMapBuilder(); - } catch (Exception $e) { - Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); - } -} else { - require_once 'lib/model/map/RolesMapBuilder.php'; - Propel::registerMapBuilder('lib.model.map.RolesMapBuilder'); -}