BaseKataoProductCategoryPeer.php 22 KB

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