/lib/model/om/BaseFcesting.php

https://github.com/cidesa/roraima-comunal · PHP · 436 lines · 299 code · 137 blank · 0 comment · 34 complexity · fff7fd22d0259b161aec5cef7ba75e1a MD5 · raw file

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