BaseKataoMemberGroupPeer.php 20 KB

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