/t/askeet/lib/model/om/BaseQuestionTag.php

https://github.com/mori-dev/emacs-symfony · PHP · 560 lines · 381 code · 179 blank · 0 comment · 63 complexity · 674d533c3f1ff4f094bcc85352e1346f MD5 · raw file

  1. <?php
  2. abstract class BaseQuestionTag extends BaseObject implements Persistent {
  3. const DATABASE_NAME = 'symfony';
  4. protected static $peer;
  5. protected $question_id;
  6. protected $user_id;
  7. protected $created_at;
  8. protected $tag;
  9. protected $normalized_tag;
  10. protected $aQuestion;
  11. protected $aUser;
  12. protected $alreadyInSave = false;
  13. protected $alreadyInValidation = false;
  14. public function getQuestionId()
  15. {
  16. return $this->question_id;
  17. }
  18. public function getUserId()
  19. {
  20. return $this->user_id;
  21. }
  22. public function getCreatedAt($format = 'Y-m-d H:i:s')
  23. {
  24. if ($this->created_at === null || $this->created_at === '') {
  25. return null;
  26. } elseif (!is_int($this->created_at)) {
  27. $ts = strtotime($this->created_at);
  28. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
  29. }
  30. } else {
  31. $ts = $this->created_at;
  32. }
  33. if ($format === null) {
  34. return $ts;
  35. } elseif (strpos($format, '%') !== false) {
  36. return strftime($format, $ts);
  37. } else {
  38. return date($format, $ts);
  39. }
  40. }
  41. public function getTag()
  42. {
  43. return $this->tag;
  44. }
  45. public function getNormalizedTag()
  46. {
  47. return $this->normalized_tag;
  48. }
  49. public function setQuestionId($v)
  50. {
  51. if ($this->question_id !== $v) {
  52. $this->question_id = $v;
  53. $this->modifiedColumns[] = QuestionTagPeer::QUESTION_ID;
  54. }
  55. if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) {
  56. $this->aQuestion = null;
  57. }
  58. }
  59. public function setUserId($v)
  60. {
  61. if ($this->user_id !== $v) {
  62. $this->user_id = $v;
  63. $this->modifiedColumns[] = QuestionTagPeer::USER_ID;
  64. }
  65. if ($this->aUser !== null && $this->aUser->getId() !== $v) {
  66. $this->aUser = null;
  67. }
  68. }
  69. public function setCreatedAt($v)
  70. {
  71. if ($v !== null && !is_int($v)) {
  72. $ts = strtotime($v);
  73. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
  74. }
  75. } else {
  76. $ts = $v;
  77. }
  78. if ($this->created_at !== $ts) {
  79. $this->created_at = $ts;
  80. $this->modifiedColumns[] = QuestionTagPeer::CREATED_AT;
  81. }
  82. }
  83. public function setTag($v)
  84. {
  85. if ($this->tag !== $v) {
  86. $this->tag = $v;
  87. $this->modifiedColumns[] = QuestionTagPeer::TAG;
  88. }
  89. }
  90. public function setNormalizedTag($v)
  91. {
  92. if ($this->normalized_tag !== $v) {
  93. $this->normalized_tag = $v;
  94. $this->modifiedColumns[] = QuestionTagPeer::NORMALIZED_TAG;
  95. }
  96. }
  97. public function hydrate(ResultSet $rs, $startcol = 1)
  98. {
  99. try {
  100. $this->question_id = $rs->getInt($startcol + 0);
  101. $this->user_id = $rs->getInt($startcol + 1);
  102. $this->created_at = $rs->getTimestamp($startcol + 2, null);
  103. $this->tag = $rs->getString($startcol + 3);
  104. $this->normalized_tag = $rs->getString($startcol + 4);
  105. $this->resetModified();
  106. $this->setNew(false);
  107. return $startcol + 5;
  108. } catch (Exception $e) {
  109. throw new PropelException("Error populating QuestionTag object", $e);
  110. }
  111. }
  112. public function delete($con = null)
  113. {
  114. if ($this->isDeleted()) {
  115. throw new PropelException("This object has already been deleted.");
  116. }
  117. if ($con === null) {
  118. $con = Propel::getConnection(QuestionTagPeer::DATABASE_NAME);
  119. }
  120. try {
  121. $con->begin();
  122. QuestionTagPeer::doDelete($this, $con);
  123. $this->setDeleted(true);
  124. $con->commit();
  125. } catch (PropelException $e) {
  126. $con->rollback();
  127. throw $e;
  128. }
  129. }
  130. public function save($con = null)
  131. {
  132. if ($this->isNew() && !$this->isColumnModified(QuestionTagPeer::CREATED_AT))
  133. {
  134. $this->setCreatedAt(time());
  135. }
  136. if ($this->isDeleted()) {
  137. throw new PropelException("You cannot save an object that has been deleted.");
  138. }
  139. if ($con === null) {
  140. $con = Propel::getConnection(QuestionTagPeer::DATABASE_NAME);
  141. }
  142. try {
  143. $con->begin();
  144. $affectedRows = $this->doSave($con);
  145. $con->commit();
  146. return $affectedRows;
  147. } catch (PropelException $e) {
  148. $con->rollback();
  149. throw $e;
  150. }
  151. }
  152. protected function doSave($con)
  153. {
  154. $affectedRows = 0; if (!$this->alreadyInSave) {
  155. $this->alreadyInSave = true;
  156. if ($this->aQuestion !== null) {
  157. if ($this->aQuestion->isModified()) {
  158. $affectedRows += $this->aQuestion->save($con);
  159. }
  160. $this->setQuestion($this->aQuestion);
  161. }
  162. if ($this->aUser !== null) {
  163. if ($this->aUser->isModified()) {
  164. $affectedRows += $this->aUser->save($con);
  165. }
  166. $this->setUser($this->aUser);
  167. }
  168. if ($this->isModified()) {
  169. if ($this->isNew()) {
  170. $pk = QuestionTagPeer::doInsert($this, $con);
  171. $affectedRows += 1;
  172. $this->setNew(false);
  173. } else {
  174. $affectedRows += QuestionTagPeer::doUpdate($this, $con);
  175. }
  176. $this->resetModified(); }
  177. $this->alreadyInSave = false;
  178. }
  179. return $affectedRows;
  180. }
  181. protected $validationFailures = array();
  182. public function getValidationFailures()
  183. {
  184. return $this->validationFailures;
  185. }
  186. public function validate($columns = null)
  187. {
  188. $res = $this->doValidate($columns);
  189. if ($res === true) {
  190. $this->validationFailures = array();
  191. return true;
  192. } else {
  193. $this->validationFailures = $res;
  194. return false;
  195. }
  196. }
  197. protected function doValidate($columns = null)
  198. {
  199. if (!$this->alreadyInValidation) {
  200. $this->alreadyInValidation = true;
  201. $retval = null;
  202. $failureMap = array();
  203. if ($this->aQuestion !== null) {
  204. if (!$this->aQuestion->validate($columns)) {
  205. $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures());
  206. }
  207. }
  208. if ($this->aUser !== null) {
  209. if (!$this->aUser->validate($columns)) {
  210. $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
  211. }
  212. }
  213. if (($retval = QuestionTagPeer::doValidate($this, $columns)) !== true) {
  214. $failureMap = array_merge($failureMap, $retval);
  215. }
  216. $this->alreadyInValidation = false;
  217. }
  218. return (!empty($failureMap) ? $failureMap : true);
  219. }
  220. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  221. {
  222. $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  223. return $this->getByPosition($pos);
  224. }
  225. public function getByPosition($pos)
  226. {
  227. switch($pos) {
  228. case 0:
  229. return $this->getQuestionId();
  230. break;
  231. case 1:
  232. return $this->getUserId();
  233. break;
  234. case 2:
  235. return $this->getCreatedAt();
  236. break;
  237. case 3:
  238. return $this->getTag();
  239. break;
  240. case 4:
  241. return $this->getNormalizedTag();
  242. break;
  243. default:
  244. return null;
  245. break;
  246. } }
  247. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  248. {
  249. $keys = QuestionTagPeer::getFieldNames($keyType);
  250. $result = array(
  251. $keys[0] => $this->getQuestionId(),
  252. $keys[1] => $this->getUserId(),
  253. $keys[2] => $this->getCreatedAt(),
  254. $keys[3] => $this->getTag(),
  255. $keys[4] => $this->getNormalizedTag(),
  256. );
  257. return $result;
  258. }
  259. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  260. {
  261. $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  262. return $this->setByPosition($pos, $value);
  263. }
  264. public function setByPosition($pos, $value)
  265. {
  266. switch($pos) {
  267. case 0:
  268. $this->setQuestionId($value);
  269. break;
  270. case 1:
  271. $this->setUserId($value);
  272. break;
  273. case 2:
  274. $this->setCreatedAt($value);
  275. break;
  276. case 3:
  277. $this->setTag($value);
  278. break;
  279. case 4:
  280. $this->setNormalizedTag($value);
  281. break;
  282. } }
  283. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  284. {
  285. $keys = QuestionTagPeer::getFieldNames($keyType);
  286. if (array_key_exists($keys[0], $arr)) $this->setQuestionId($arr[$keys[0]]);
  287. if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]);
  288. if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
  289. if (array_key_exists($keys[3], $arr)) $this->setTag($arr[$keys[3]]);
  290. if (array_key_exists($keys[4], $arr)) $this->setNormalizedTag($arr[$keys[4]]);
  291. }
  292. public function buildCriteria()
  293. {
  294. $criteria = new Criteria(QuestionTagPeer::DATABASE_NAME);
  295. if ($this->isColumnModified(QuestionTagPeer::QUESTION_ID)) $criteria->add(QuestionTagPeer::QUESTION_ID, $this->question_id);
  296. if ($this->isColumnModified(QuestionTagPeer::USER_ID)) $criteria->add(QuestionTagPeer::USER_ID, $this->user_id);
  297. if ($this->isColumnModified(QuestionTagPeer::CREATED_AT)) $criteria->add(QuestionTagPeer::CREATED_AT, $this->created_at);
  298. if ($this->isColumnModified(QuestionTagPeer::TAG)) $criteria->add(QuestionTagPeer::TAG, $this->tag);
  299. if ($this->isColumnModified(QuestionTagPeer::NORMALIZED_TAG)) $criteria->add(QuestionTagPeer::NORMALIZED_TAG, $this->normalized_tag);
  300. return $criteria;
  301. }
  302. public function buildPkeyCriteria()
  303. {
  304. $criteria = new Criteria(QuestionTagPeer::DATABASE_NAME);
  305. $criteria->add(QuestionTagPeer::QUESTION_ID, $this->question_id);
  306. $criteria->add(QuestionTagPeer::USER_ID, $this->user_id);
  307. $criteria->add(QuestionTagPeer::NORMALIZED_TAG, $this->normalized_tag);
  308. return $criteria;
  309. }
  310. public function getPrimaryKey()
  311. {
  312. $pks = array();
  313. $pks[0] = $this->getQuestionId();
  314. $pks[1] = $this->getUserId();
  315. $pks[2] = $this->getNormalizedTag();
  316. return $pks;
  317. }
  318. public function setPrimaryKey($keys)
  319. {
  320. $this->setQuestionId($keys[0]);
  321. $this->setUserId($keys[1]);
  322. $this->setNormalizedTag($keys[2]);
  323. }
  324. public function copyInto($copyObj, $deepCopy = false)
  325. {
  326. $copyObj->setCreatedAt($this->created_at);
  327. $copyObj->setTag($this->tag);
  328. $copyObj->setNew(true);
  329. $copyObj->setQuestionId(NULL);
  330. $copyObj->setUserId(NULL);
  331. $copyObj->setNormalizedTag(NULL);
  332. }
  333. public function copy($deepCopy = false)
  334. {
  335. $clazz = get_class($this);
  336. $copyObj = new $clazz();
  337. $this->copyInto($copyObj, $deepCopy);
  338. return $copyObj;
  339. }
  340. public function getPeer()
  341. {
  342. if (self::$peer === null) {
  343. self::$peer = new QuestionTagPeer();
  344. }
  345. return self::$peer;
  346. }
  347. public function setQuestion($v)
  348. {
  349. if ($v === null) {
  350. $this->setQuestionId(NULL);
  351. } else {
  352. $this->setQuestionId($v->getId());
  353. }
  354. $this->aQuestion = $v;
  355. }
  356. public function getQuestion($con = null)
  357. {
  358. include_once 'lib/model/om/BaseQuestionPeer.php';
  359. if ($this->aQuestion === null && ($this->question_id !== null)) {
  360. $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con);
  361. }
  362. return $this->aQuestion;
  363. }
  364. public function setUser($v)
  365. {
  366. if ($v === null) {
  367. $this->setUserId(NULL);
  368. } else {
  369. $this->setUserId($v->getId());
  370. }
  371. $this->aUser = $v;
  372. }
  373. public function getUser($con = null)
  374. {
  375. include_once 'lib/model/om/BaseUserPeer.php';
  376. if ($this->aUser === null && ($this->user_id !== null)) {
  377. $this->aUser = UserPeer::retrieveByPK($this->user_id, $con);
  378. }
  379. return $this->aUser;
  380. }
  381. }