/lib/model/om/BaseAlbaConfig.php

https://github.com/proyectoalba/alba · PHP · 420 lines · 301 code · 119 blank · 0 comment · 34 complexity · ed7ecc78d404117a4b2173844f5f4988 MD5 · raw file

  1. <?php
  2. abstract class BaseAlbaConfig extends BaseObject implements Persistent {
  3. const PEER = 'AlbaConfigPeer';
  4. protected static $peer;
  5. protected $id;
  6. protected $nombre;
  7. protected $valor;
  8. protected $alreadyInSave = false;
  9. protected $alreadyInValidation = false;
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. $this->applyDefaultValues();
  14. }
  15. public function applyDefaultValues()
  16. {
  17. }
  18. public function getId()
  19. {
  20. return $this->id;
  21. }
  22. public function getNombre()
  23. {
  24. return $this->nombre;
  25. }
  26. public function getValor()
  27. {
  28. return $this->valor;
  29. }
  30. public function setId($v)
  31. {
  32. if ($v !== null) {
  33. $v = (int) $v;
  34. }
  35. if ($this->id !== $v) {
  36. $this->id = $v;
  37. $this->modifiedColumns[] = AlbaConfigPeer::ID;
  38. }
  39. return $this;
  40. }
  41. public function setNombre($v)
  42. {
  43. if ($v !== null) {
  44. $v = (string) $v;
  45. }
  46. if ($this->nombre !== $v) {
  47. $this->nombre = $v;
  48. $this->modifiedColumns[] = AlbaConfigPeer::NOMBRE;
  49. }
  50. return $this;
  51. }
  52. public function setValor($v)
  53. {
  54. if ($v !== null) {
  55. $v = (string) $v;
  56. }
  57. if ($this->valor !== $v) {
  58. $this->valor = $v;
  59. $this->modifiedColumns[] = AlbaConfigPeer::VALOR;
  60. }
  61. return $this;
  62. }
  63. public function hasOnlyDefaultValues()
  64. {
  65. if (array_diff($this->modifiedColumns, array())) {
  66. return false;
  67. }
  68. return true;
  69. }
  70. public function hydrate($row, $startcol = 0, $rehydrate = false)
  71. {
  72. try {
  73. $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
  74. $this->nombre = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
  75. $this->valor = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
  76. $this->resetModified();
  77. $this->setNew(false);
  78. if ($rehydrate) {
  79. $this->ensureConsistency();
  80. }
  81. return $startcol + 3;
  82. } catch (Exception $e) {
  83. throw new PropelException("Error populating AlbaConfig object", $e);
  84. }
  85. }
  86. public function ensureConsistency()
  87. {
  88. }
  89. public function reload($deep = false, PropelPDO $con = null)
  90. {
  91. if ($this->isDeleted()) {
  92. throw new PropelException("Cannot reload a deleted object.");
  93. }
  94. if ($this->isNew()) {
  95. throw new PropelException("Cannot reload an unsaved object.");
  96. }
  97. if ($con === null) {
  98. $con = Propel::getConnection(AlbaConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  99. }
  100. $stmt = AlbaConfigPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  101. $row = $stmt->fetch(PDO::FETCH_NUM);
  102. $stmt->closeCursor();
  103. if (!$row) {
  104. throw new PropelException('Cannot find matching row in the database to reload object values.');
  105. }
  106. $this->hydrate($row, 0, true);
  107. if ($deep) {
  108. } }
  109. public function delete(PropelPDO $con = null)
  110. {
  111. if ($this->isDeleted()) {
  112. throw new PropelException("This object has already been deleted.");
  113. }
  114. if ($con === null) {
  115. $con = Propel::getConnection(AlbaConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  116. }
  117. $con->beginTransaction();
  118. try {
  119. AlbaConfigPeer::doDelete($this, $con);
  120. $this->setDeleted(true);
  121. $con->commit();
  122. } catch (PropelException $e) {
  123. $con->rollBack();
  124. throw $e;
  125. }
  126. }
  127. public function save(PropelPDO $con = null)
  128. {
  129. if ($this->isDeleted()) {
  130. throw new PropelException("You cannot save an object that has been deleted.");
  131. }
  132. if ($con === null) {
  133. $con = Propel::getConnection(AlbaConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  134. }
  135. $con->beginTransaction();
  136. try {
  137. $affectedRows = $this->doSave($con);
  138. $con->commit();
  139. AlbaConfigPeer::addInstanceToPool($this);
  140. return $affectedRows;
  141. } catch (PropelException $e) {
  142. $con->rollBack();
  143. throw $e;
  144. }
  145. }
  146. protected function doSave(PropelPDO $con)
  147. {
  148. $affectedRows = 0; if (!$this->alreadyInSave) {
  149. $this->alreadyInSave = true;
  150. if ($this->isNew() ) {
  151. $this->modifiedColumns[] = AlbaConfigPeer::ID;
  152. }
  153. if ($this->isModified()) {
  154. if ($this->isNew()) {
  155. $pk = AlbaConfigPeer::doInsert($this, $con);
  156. $affectedRows += 1;
  157. $this->setId($pk);
  158. $this->setNew(false);
  159. } else {
  160. $affectedRows += AlbaConfigPeer::doUpdate($this, $con);
  161. }
  162. $this->resetModified(); }
  163. $this->alreadyInSave = false;
  164. }
  165. return $affectedRows;
  166. }
  167. protected $validationFailures = array();
  168. public function getValidationFailures()
  169. {
  170. return $this->validationFailures;
  171. }
  172. public function validate($columns = null)
  173. {
  174. $res = $this->doValidate($columns);
  175. if ($res === true) {
  176. $this->validationFailures = array();
  177. return true;
  178. } else {
  179. $this->validationFailures = $res;
  180. return false;
  181. }
  182. }
  183. protected function doValidate($columns = null)
  184. {
  185. if (!$this->alreadyInValidation) {
  186. $this->alreadyInValidation = true;
  187. $retval = null;
  188. $failureMap = array();
  189. if (($retval = AlbaConfigPeer::doValidate($this, $columns)) !== true) {
  190. $failureMap = array_merge($failureMap, $retval);
  191. }
  192. $this->alreadyInValidation = false;
  193. }
  194. return (!empty($failureMap) ? $failureMap : true);
  195. }
  196. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  197. {
  198. $pos = AlbaConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  199. $field = $this->getByPosition($pos);
  200. return $field;
  201. }
  202. public function getByPosition($pos)
  203. {
  204. switch($pos) {
  205. case 0:
  206. return $this->getId();
  207. break;
  208. case 1:
  209. return $this->getNombre();
  210. break;
  211. case 2:
  212. return $this->getValor();
  213. break;
  214. default:
  215. return null;
  216. break;
  217. } }
  218. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
  219. {
  220. $keys = AlbaConfigPeer::getFieldNames($keyType);
  221. $result = array(
  222. $keys[0] => $this->getId(),
  223. $keys[1] => $this->getNombre(),
  224. $keys[2] => $this->getValor(),
  225. );
  226. return $result;
  227. }
  228. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  229. {
  230. $pos = AlbaConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  231. return $this->setByPosition($pos, $value);
  232. }
  233. public function setByPosition($pos, $value)
  234. {
  235. switch($pos) {
  236. case 0:
  237. $this->setId($value);
  238. break;
  239. case 1:
  240. $this->setNombre($value);
  241. break;
  242. case 2:
  243. $this->setValor($value);
  244. break;
  245. } }
  246. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  247. {
  248. $keys = AlbaConfigPeer::getFieldNames($keyType);
  249. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  250. if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]]);
  251. if (array_key_exists($keys[2], $arr)) $this->setValor($arr[$keys[2]]);
  252. }
  253. public function buildCriteria()
  254. {
  255. $criteria = new Criteria(AlbaConfigPeer::DATABASE_NAME);
  256. if ($this->isColumnModified(AlbaConfigPeer::ID)) $criteria->add(AlbaConfigPeer::ID, $this->id);
  257. if ($this->isColumnModified(AlbaConfigPeer::NOMBRE)) $criteria->add(AlbaConfigPeer::NOMBRE, $this->nombre);
  258. if ($this->isColumnModified(AlbaConfigPeer::VALOR)) $criteria->add(AlbaConfigPeer::VALOR, $this->valor);
  259. return $criteria;
  260. }
  261. public function buildPkeyCriteria()
  262. {
  263. $criteria = new Criteria(AlbaConfigPeer::DATABASE_NAME);
  264. $criteria->add(AlbaConfigPeer::ID, $this->id);
  265. return $criteria;
  266. }
  267. public function getPrimaryKey()
  268. {
  269. return $this->getId();
  270. }
  271. public function setPrimaryKey($key)
  272. {
  273. $this->setId($key);
  274. }
  275. public function copyInto($copyObj, $deepCopy = false)
  276. {
  277. $copyObj->setNombre($this->nombre);
  278. $copyObj->setValor($this->valor);
  279. $copyObj->setNew(true);
  280. $copyObj->setId(NULL);
  281. }
  282. public function copy($deepCopy = false)
  283. {
  284. $clazz = get_class($this);
  285. $copyObj = new $clazz();
  286. $this->copyInto($copyObj, $deepCopy);
  287. return $copyObj;
  288. }
  289. public function getPeer()
  290. {
  291. if (self::$peer === null) {
  292. self::$peer = new AlbaConfigPeer();
  293. }
  294. return self::$peer;
  295. }
  296. public function clearAllReferences($deep = false)
  297. {
  298. if ($deep) {
  299. }
  300. }
  301. }