BaseKataoPeriodPeer.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'katao_period' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseKataoPeriodPeer {
  10. /** the default database name for this class */
  11. const DATABASE_NAME = 'propel';
  12. /** the table name for this class */
  13. const TABLE_NAME = 'katao_period';
  14. /** A class that can be returned by this peer. */
  15. const CLASS_DEFAULT = 'lib.model.KataoPeriod';
  16. /** The total number of columns. */
  17. const NUM_COLUMNS = 9;
  18. /** The number of lazy-loaded columns. */
  19. const NUM_LAZY_LOAD_COLUMNS = 0;
  20. /** the column name for the ID field */
  21. const ID = 'katao_period.ID';
  22. /** the column name for the NAME field */
  23. const NAME = 'katao_period.NAME';
  24. /** the column name for the BEGIN_AT field */
  25. const BEGIN_AT = 'katao_period.BEGIN_AT';
  26. /** the column name for the FINISH_AT field */
  27. const FINISH_AT = 'katao_period.FINISH_AT';
  28. /** the column name for the ORDER_ENDED_AT field */
  29. const ORDER_ENDED_AT = 'katao_period.ORDER_ENDED_AT';
  30. /** the column name for the STATUS field */
  31. const STATUS = 'katao_period.STATUS';
  32. /** the column name for the EXPORTED field */
  33. const EXPORTED = 'katao_period.EXPORTED';
  34. /** the column name for the CREATED_AT field */
  35. const CREATED_AT = 'katao_period.CREATED_AT';
  36. /** the column name for the UPDATED_AT field */
  37. const UPDATED_AT = 'katao_period.UPDATED_AT';
  38. /** The PHP to DB Name Mapping */
  39. private static $phpNameMap = null;
  40. /**
  41. * holds an array of fieldnames
  42. *
  43. * first dimension keys are the type constants
  44. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  45. */
  46. private static $fieldNames = array (
  47. BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'BeginAt', 'FinishAt', 'OrderEndedAt', 'Status', 'Exported', 'CreatedAt', 'UpdatedAt', ),
  48. BasePeer::TYPE_COLNAME => array (KataoPeriodPeer::ID, KataoPeriodPeer::NAME, KataoPeriodPeer::BEGIN_AT, KataoPeriodPeer::FINISH_AT, KataoPeriodPeer::ORDER_ENDED_AT, KataoPeriodPeer::STATUS, KataoPeriodPeer::EXPORTED, KataoPeriodPeer::CREATED_AT, KataoPeriodPeer::UPDATED_AT, ),
  49. BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'begin_at', 'finish_at', 'order_ended_at', 'status', 'exported', 'created_at', 'updated_at', ),
  50. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
  51. );
  52. /**
  53. * holds an array of keys for quick access to the fieldnames array
  54. *
  55. * first dimension keys are the type constants
  56. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  57. */
  58. private static $fieldKeys = array (
  59. BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'BeginAt' => 2, 'FinishAt' => 3, 'OrderEndedAt' => 4, 'Status' => 5, 'Exported' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
  60. BasePeer::TYPE_COLNAME => array (KataoPeriodPeer::ID => 0, KataoPeriodPeer::NAME => 1, KataoPeriodPeer::BEGIN_AT => 2, KataoPeriodPeer::FINISH_AT => 3, KataoPeriodPeer::ORDER_ENDED_AT => 4, KataoPeriodPeer::STATUS => 5, KataoPeriodPeer::EXPORTED => 6, KataoPeriodPeer::CREATED_AT => 7, KataoPeriodPeer::UPDATED_AT => 8, ),
  61. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'begin_at' => 2, 'finish_at' => 3, 'order_ended_at' => 4, 'status' => 5, 'exported' => 6, 'created_at' => 7, 'updated_at' => 8, ),
  62. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
  63. );
  64. /**
  65. * @return MapBuilder the map builder for this peer
  66. * @throws PropelException Any exceptions caught during processing will be
  67. * rethrown wrapped into a PropelException.
  68. */
  69. public static function getMapBuilder()
  70. {
  71. return BasePeer::getMapBuilder('lib.model.map.KataoPeriodMapBuilder');
  72. }
  73. /**
  74. * Gets a map (hash) of PHP names to DB column names.
  75. *
  76. * @return array The PHP to DB name map for this peer
  77. * @throws PropelException Any exceptions caught during processing will be
  78. * rethrown wrapped into a PropelException.
  79. * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
  80. */
  81. public static function getPhpNameMap()
  82. {
  83. if (self::$phpNameMap === null) {
  84. $map = KataoPeriodPeer::getTableMap();
  85. $columns = $map->getColumns();
  86. $nameMap = array();
  87. foreach ($columns as $column) {
  88. $nameMap[$column->getPhpName()] = $column->getColumnName();
  89. }
  90. self::$phpNameMap = $nameMap;
  91. }
  92. return self::$phpNameMap;
  93. }
  94. /**
  95. * Translates a fieldname to another type
  96. *
  97. * @param string $name field name
  98. * @param string $fromType One of the class type constants TYPE_PHPNAME,
  99. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  100. * @param string $toType One of the class type constants
  101. * @return string translated name of the field.
  102. */
  103. static public function translateFieldName($name, $fromType, $toType)
  104. {
  105. $toNames = self::getFieldNames($toType);
  106. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  107. if ($key === null) {
  108. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  109. }
  110. return $toNames[$key];
  111. }
  112. /**
  113. * Returns an array of of field names.
  114. *
  115. * @param string $type The type of fieldnames to return:
  116. * One of the class type constants TYPE_PHPNAME,
  117. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  118. * @return array A list of field names
  119. */
  120. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  121. {
  122. if (!array_key_exists($type, self::$fieldNames)) {
  123. 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.');
  124. }
  125. return self::$fieldNames[$type];
  126. }
  127. /**
  128. * Convenience method which changes table.column to alias.column.
  129. *
  130. * Using this method you can maintain SQL abstraction while using column aliases.
  131. * <code>
  132. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  133. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  134. * </code>
  135. * @param string $alias The alias for the current table.
  136. * @param string $column The column name for current table. (i.e. KataoPeriodPeer::COLUMN_NAME).
  137. * @return string
  138. */
  139. public static function alias($alias, $column)
  140. {
  141. return str_replace(KataoPeriodPeer::TABLE_NAME.'.', $alias.'.', $column);
  142. }
  143. /**
  144. * Add all the columns needed to create a new object.
  145. *
  146. * Note: any columns that were marked with lazyLoad="true" in the
  147. * XML schema will not be added to the select list and only loaded
  148. * on demand.
  149. *
  150. * @param criteria object containing the columns to add.
  151. * @throws PropelException Any exceptions caught during processing will be
  152. * rethrown wrapped into a PropelException.
  153. */
  154. public static function addSelectColumns(Criteria $criteria)
  155. {
  156. $criteria->addSelectColumn(KataoPeriodPeer::ID);
  157. $criteria->addSelectColumn(KataoPeriodPeer::NAME);
  158. $criteria->addSelectColumn(KataoPeriodPeer::BEGIN_AT);
  159. $criteria->addSelectColumn(KataoPeriodPeer::FINISH_AT);
  160. $criteria->addSelectColumn(KataoPeriodPeer::ORDER_ENDED_AT);
  161. $criteria->addSelectColumn(KataoPeriodPeer::STATUS);
  162. $criteria->addSelectColumn(KataoPeriodPeer::EXPORTED);
  163. $criteria->addSelectColumn(KataoPeriodPeer::CREATED_AT);
  164. $criteria->addSelectColumn(KataoPeriodPeer::UPDATED_AT);
  165. }
  166. const COUNT = 'COUNT(katao_period.ID)';
  167. const COUNT_DISTINCT = 'COUNT(DISTINCT katao_period.ID)';
  168. /**
  169. * Returns the number of rows matching criteria.
  170. *
  171. * @param Criteria $criteria
  172. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  173. * @param Connection $con
  174. * @return int Number of matching rows.
  175. */
  176. public static function doCount(Criteria $criteria, $distinct = false, $con = null)
  177. {
  178. // we're going to modify criteria, so copy it first
  179. $criteria = clone $criteria;
  180. // clear out anything that might confuse the ORDER BY clause
  181. $criteria->clearSelectColumns()->clearOrderByColumns();
  182. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  183. $criteria->addSelectColumn(KataoPeriodPeer::COUNT_DISTINCT);
  184. } else {
  185. $criteria->addSelectColumn(KataoPeriodPeer::COUNT);
  186. }
  187. // just in case we're grouping: add those columns to the select statement
  188. foreach($criteria->getGroupByColumns() as $column)
  189. {
  190. $criteria->addSelectColumn($column);
  191. }
  192. $rs = KataoPeriodPeer::doSelectRS($criteria, $con);
  193. if ($rs->next()) {
  194. return $rs->getInt(1);
  195. } else {
  196. // no rows returned; we infer that means 0 matches.
  197. return 0;
  198. }
  199. }
  200. /**
  201. * Method to select one object from the DB.
  202. *
  203. * @param Criteria $criteria object used to create the SELECT statement.
  204. * @param Connection $con
  205. * @return KataoPeriod
  206. * @throws PropelException Any exceptions caught during processing will be
  207. * rethrown wrapped into a PropelException.
  208. */
  209. public static function doSelectOne(Criteria $criteria, $con = null)
  210. {
  211. $critcopy = clone $criteria;
  212. $critcopy->setLimit(1);
  213. $objects = KataoPeriodPeer::doSelect($critcopy, $con);
  214. if ($objects) {
  215. return $objects[0];
  216. }
  217. return null;
  218. }
  219. /**
  220. * Method to do selects.
  221. *
  222. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  223. * @param Connection $con
  224. * @return array Array of selected Objects
  225. * @throws PropelException Any exceptions caught during processing will be
  226. * rethrown wrapped into a PropelException.
  227. */
  228. public static function doSelect(Criteria $criteria, $con = null)
  229. {
  230. return KataoPeriodPeer::populateObjects(KataoPeriodPeer::doSelectRS($criteria, $con));
  231. }
  232. /**
  233. * Prepares the Criteria object and uses the parent doSelect()
  234. * method to get a ResultSet.
  235. *
  236. * Use this method directly if you want to just get the resultset
  237. * (instead of an array of objects).
  238. *
  239. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  240. * @param Connection $con the connection to use
  241. * @throws PropelException Any exceptions caught during processing will be
  242. * rethrown wrapped into a PropelException.
  243. * @return ResultSet The resultset object with numerically-indexed fields.
  244. * @see BasePeer::doSelect()
  245. */
  246. public static function doSelectRS(Criteria $criteria, $con = null)
  247. {
  248. foreach (sfMixer::getCallables('BaseKataoPeriodPeer:doSelectRS:doSelectRS') as $callable)
  249. {
  250. call_user_func($callable, 'BaseKataoPeriodPeer', $criteria, $con);
  251. }
  252. if ($con === null) {
  253. $con = Propel::getConnection(self::DATABASE_NAME);
  254. }
  255. if (!$criteria->getSelectColumns()) {
  256. $criteria = clone $criteria;
  257. KataoPeriodPeer::addSelectColumns($criteria);
  258. }
  259. // Set the correct dbName
  260. $criteria->setDbName(self::DATABASE_NAME);
  261. // BasePeer returns a Creole ResultSet, set to return
  262. // rows indexed numerically.
  263. return BasePeer::doSelect($criteria, $con);
  264. }
  265. /**
  266. * The returned array will contain objects of the default type or
  267. * objects that inherit from the default.
  268. *
  269. * @throws PropelException Any exceptions caught during processing will be
  270. * rethrown wrapped into a PropelException.
  271. */
  272. public static function populateObjects(ResultSet $rs)
  273. {
  274. $results = array();
  275. // set the class once to avoid overhead in the loop
  276. $cls = KataoPeriodPeer::getOMClass();
  277. $cls = sfPropel::import($cls);
  278. // populate the object(s)
  279. while($rs->next()) {
  280. $obj = new $cls();
  281. $obj->hydrate($rs);
  282. $results[] = $obj;
  283. }
  284. return $results;
  285. }
  286. static public function getUniqueColumnNames()
  287. {
  288. return array();
  289. }
  290. /**
  291. * Returns the TableMap related to this peer.
  292. * This method is not needed for general use but a specific application could have a need.
  293. * @return TableMap
  294. * @throws PropelException Any exceptions caught during processing will be
  295. * rethrown wrapped into a PropelException.
  296. */
  297. public static function getTableMap()
  298. {
  299. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  300. }
  301. /**
  302. * The class that the Peer will make instances of.
  303. *
  304. * This uses a dot-path notation which is tranalted into a path
  305. * relative to a location on the PHP include_path.
  306. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  307. *
  308. * @return string path.to.ClassName
  309. */
  310. public static function getOMClass()
  311. {
  312. return KataoPeriodPeer::CLASS_DEFAULT;
  313. }
  314. /**
  315. * Method perform an INSERT on the database, given a KataoPeriod or Criteria object.
  316. *
  317. * @param mixed $values Criteria or KataoPeriod object containing data that is used to create the INSERT statement.
  318. * @param Connection $con the connection to use
  319. * @return mixed The new primary key.
  320. * @throws PropelException Any exceptions caught during processing will be
  321. * rethrown wrapped into a PropelException.
  322. */
  323. public static function doInsert($values, $con = null)
  324. {
  325. foreach (sfMixer::getCallables('BaseKataoPeriodPeer:doInsert:pre') as $callable)
  326. {
  327. $ret = call_user_func($callable, 'BaseKataoPeriodPeer', $values, $con);
  328. if (false !== $ret)
  329. {
  330. return $ret;
  331. }
  332. }
  333. if ($con === null) {
  334. $con = Propel::getConnection(self::DATABASE_NAME);
  335. }
  336. if ($values instanceof Criteria) {
  337. $criteria = clone $values; // rename for clarity
  338. } else {
  339. $criteria = $values->buildCriteria(); // build Criteria from KataoPeriod object
  340. }
  341. $criteria->remove(KataoPeriodPeer::ID); // remove pkey col since this table uses auto-increment
  342. // Set the correct dbName
  343. $criteria->setDbName(self::DATABASE_NAME);
  344. try {
  345. // use transaction because $criteria could contain info
  346. // for more than one table (I guess, conceivably)
  347. $con->begin();
  348. $pk = BasePeer::doInsert($criteria, $con);
  349. $con->commit();
  350. } catch(PropelException $e) {
  351. $con->rollback();
  352. throw $e;
  353. }
  354. foreach (sfMixer::getCallables('BaseKataoPeriodPeer:doInsert:post') as $callable)
  355. {
  356. call_user_func($callable, 'BaseKataoPeriodPeer', $values, $con, $pk);
  357. }
  358. return $pk;
  359. }
  360. /**
  361. * Method perform an UPDATE on the database, given a KataoPeriod or Criteria object.
  362. *
  363. * @param mixed $values Criteria or KataoPeriod object containing data that is used to create the UPDATE statement.
  364. * @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
  365. * @return int The number of affected rows (if supported by underlying database driver).
  366. * @throws PropelException Any exceptions caught during processing will be
  367. * rethrown wrapped into a PropelException.
  368. */
  369. public static function doUpdate($values, $con = null)
  370. {
  371. foreach (sfMixer::getCallables('BaseKataoPeriodPeer:doUpdate:pre') as $callable)
  372. {
  373. $ret = call_user_func($callable, 'BaseKataoPeriodPeer', $values, $con);
  374. if (false !== $ret)
  375. {
  376. return $ret;
  377. }
  378. }
  379. if ($con === null) {
  380. $con = Propel::getConnection(self::DATABASE_NAME);
  381. }
  382. $selectCriteria = new Criteria(self::DATABASE_NAME);
  383. if ($values instanceof Criteria) {
  384. $criteria = clone $values; // rename for clarity
  385. $comparison = $criteria->getComparison(KataoPeriodPeer::ID);
  386. $selectCriteria->add(KataoPeriodPeer::ID, $criteria->remove(KataoPeriodPeer::ID), $comparison);
  387. } else { // $values is KataoPeriod object
  388. $criteria = $values->buildCriteria(); // gets full criteria
  389. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  390. }
  391. // set the correct dbName
  392. $criteria->setDbName(self::DATABASE_NAME);
  393. $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
  394. foreach (sfMixer::getCallables('BaseKataoPeriodPeer:doUpdate:post') as $callable)
  395. {
  396. call_user_func($callable, 'BaseKataoPeriodPeer', $values, $con, $ret);
  397. }
  398. return $ret;
  399. }
  400. /**
  401. * Method to DELETE all rows from the katao_period table.
  402. *
  403. * @return int The number of affected rows (if supported by underlying database driver).
  404. */
  405. public static function doDeleteAll($con = null)
  406. {
  407. if ($con === null) {
  408. $con = Propel::getConnection(self::DATABASE_NAME);
  409. }
  410. $affectedRows = 0; // initialize var to track total num of affected rows
  411. try {
  412. // use transaction because $criteria could contain info
  413. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  414. $con->begin();
  415. $affectedRows += BasePeer::doDeleteAll(KataoPeriodPeer::TABLE_NAME, $con);
  416. $con->commit();
  417. return $affectedRows;
  418. } catch (PropelException $e) {
  419. $con->rollback();
  420. throw $e;
  421. }
  422. }
  423. /**
  424. * Method perform a DELETE on the database, given a KataoPeriod or Criteria object OR a primary key value.
  425. *
  426. * @param mixed $values Criteria or KataoPeriod object or primary key or array of primary keys
  427. * which is used to create the DELETE statement
  428. * @param Connection $con the connection to use
  429. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  430. * if supported by native driver or if emulated using Propel.
  431. * @throws PropelException Any exceptions caught during processing will be
  432. * rethrown wrapped into a PropelException.
  433. */
  434. public static function doDelete($values, $con = null)
  435. {
  436. if ($con === null) {
  437. $con = Propel::getConnection(KataoPeriodPeer::DATABASE_NAME);
  438. }
  439. if ($values instanceof Criteria) {
  440. $criteria = clone $values; // rename for clarity
  441. } elseif ($values instanceof KataoPeriod) {
  442. $criteria = $values->buildPkeyCriteria();
  443. } else {
  444. // it must be the primary key
  445. $criteria = new Criteria(self::DATABASE_NAME);
  446. $criteria->add(KataoPeriodPeer::ID, (array) $values, Criteria::IN);
  447. }
  448. // Set the correct dbName
  449. $criteria->setDbName(self::DATABASE_NAME);
  450. $affectedRows = 0; // initialize var to track total num of affected rows
  451. try {
  452. // use transaction because $criteria could contain info
  453. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  454. $con->begin();
  455. $affectedRows += BasePeer::doDelete($criteria, $con);
  456. $con->commit();
  457. return $affectedRows;
  458. } catch (PropelException $e) {
  459. $con->rollback();
  460. throw $e;
  461. }
  462. }
  463. /**
  464. * Validates all modified columns of given KataoPeriod object.
  465. * If parameter $columns is either a single column name or an array of column names
  466. * than only those columns are validated.
  467. *
  468. * NOTICE: This does not apply to primary or foreign keys for now.
  469. *
  470. * @param KataoPeriod $obj The object to validate.
  471. * @param mixed $cols Column name or array of column names.
  472. *
  473. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  474. */
  475. public static function doValidate(KataoPeriod $obj, $cols = null)
  476. {
  477. $columns = array();
  478. if ($cols) {
  479. $dbMap = Propel::getDatabaseMap(KataoPeriodPeer::DATABASE_NAME);
  480. $tableMap = $dbMap->getTable(KataoPeriodPeer::TABLE_NAME);
  481. if (! is_array($cols)) {
  482. $cols = array($cols);
  483. }
  484. foreach($cols as $colName) {
  485. if ($tableMap->containsColumn($colName)) {
  486. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  487. $columns[$colName] = $obj->$get();
  488. }
  489. }
  490. } else {
  491. }
  492. $res = BasePeer::doValidate(KataoPeriodPeer::DATABASE_NAME, KataoPeriodPeer::TABLE_NAME, $columns);
  493. if ($res !== true) {
  494. $request = sfContext::getInstance()->getRequest();
  495. foreach ($res as $failed) {
  496. $col = KataoPeriodPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
  497. $request->setError($col, $failed->getMessage());
  498. }
  499. }
  500. return $res;
  501. }
  502. /**
  503. * Retrieve a single object by pkey.
  504. *
  505. * @param mixed $pk the primary key.
  506. * @param Connection $con the connection to use
  507. * @return KataoPeriod
  508. */
  509. public static function retrieveByPK($pk, $con = null)
  510. {
  511. if ($con === null) {
  512. $con = Propel::getConnection(self::DATABASE_NAME);
  513. }
  514. $criteria = new Criteria(KataoPeriodPeer::DATABASE_NAME);
  515. $criteria->add(KataoPeriodPeer::ID, $pk);
  516. $v = KataoPeriodPeer::doSelect($criteria, $con);
  517. return !empty($v) > 0 ? $v[0] : null;
  518. }
  519. /**
  520. * Retrieve multiple objects by pkey.
  521. *
  522. * @param array $pks List of primary keys
  523. * @param Connection $con the connection to use
  524. * @throws PropelException Any exceptions caught during processing will be
  525. * rethrown wrapped into a PropelException.
  526. */
  527. public static function retrieveByPKs($pks, $con = null)
  528. {
  529. if ($con === null) {
  530. $con = Propel::getConnection(self::DATABASE_NAME);
  531. }
  532. $objs = null;
  533. if (empty($pks)) {
  534. $objs = array();
  535. } else {
  536. $criteria = new Criteria();
  537. $criteria->add(KataoPeriodPeer::ID, $pks, Criteria::IN);
  538. $objs = KataoPeriodPeer::doSelect($criteria, $con);
  539. }
  540. return $objs;
  541. }
  542. } // BaseKataoPeriodPeer
  543. // static code to register the map builder for this Peer with the main Propel class
  544. if (Propel::isInit()) {
  545. // the MapBuilder classes register themselves with Propel during initialization
  546. // so we need to load them here.
  547. try {
  548. BaseKataoPeriodPeer::getMapBuilder();
  549. } catch (Exception $e) {
  550. Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
  551. }
  552. } else {
  553. // even if Propel is not yet initialized, the map builder class can be registered
  554. // now and then it will be loaded when Propel initializes.
  555. Propel::registerMapBuilder('lib.model.map.KataoPeriodMapBuilder');
  556. }