PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/model/om/BaseCiniveles.php

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