BaseKataoPeriodProductPeer.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'katao_period_product' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseKataoPeriodProductPeer {
  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_product';
  14. /** A class that can be returned by this peer. */
  15. const CLASS_DEFAULT = 'lib.model.KataoPeriodProduct';
  16. /** The total number of columns. */
  17. const NUM_COLUMNS = 3;
  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_product.ID';
  22. /** the column name for the KATAO_PERIOD_ID field */
  23. const KATAO_PERIOD_ID = 'katao_period_product.KATAO_PERIOD_ID';
  24. /** the column name for the KATAO_PRODUCT_ID field */
  25. const KATAO_PRODUCT_ID = 'katao_period_product.KATAO_PRODUCT_ID';
  26. /** The PHP to DB Name Mapping */
  27. private static $phpNameMap = null;
  28. /**
  29. * holds an array of fieldnames
  30. *
  31. * first dimension keys are the type constants
  32. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  33. */
  34. private static $fieldNames = array (
  35. BasePeer::TYPE_PHPNAME => array ('Id', 'KataoPeriodId', 'KataoProductId', ),
  36. BasePeer::TYPE_COLNAME => array (KataoPeriodProductPeer::ID, KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodProductPeer::KATAO_PRODUCT_ID, ),
  37. BasePeer::TYPE_FIELDNAME => array ('id', 'katao_period_id', 'katao_product_id', ),
  38. BasePeer::TYPE_NUM => array (0, 1, 2, )
  39. );
  40. /**
  41. * holds an array of keys for quick access to the fieldnames array
  42. *
  43. * first dimension keys are the type constants
  44. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  45. */
  46. private static $fieldKeys = array (
  47. BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'KataoPeriodId' => 1, 'KataoProductId' => 2, ),
  48. BasePeer::TYPE_COLNAME => array (KataoPeriodProductPeer::ID => 0, KataoPeriodProductPeer::KATAO_PERIOD_ID => 1, KataoPeriodProductPeer::KATAO_PRODUCT_ID => 2, ),
  49. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'katao_period_id' => 1, 'katao_product_id' => 2, ),
  50. BasePeer::TYPE_NUM => array (0, 1, 2, )
  51. );
  52. /**
  53. * @return MapBuilder the map builder for this peer
  54. * @throws PropelException Any exceptions caught during processing will be
  55. * rethrown wrapped into a PropelException.
  56. */
  57. public static function getMapBuilder()
  58. {
  59. return BasePeer::getMapBuilder('lib.model.map.KataoPeriodProductMapBuilder');
  60. }
  61. /**
  62. * Gets a map (hash) of PHP names to DB column names.
  63. *
  64. * @return array The PHP to DB name map for this peer
  65. * @throws PropelException Any exceptions caught during processing will be
  66. * rethrown wrapped into a PropelException.
  67. * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
  68. */
  69. public static function getPhpNameMap()
  70. {
  71. if (self::$phpNameMap === null) {
  72. $map = KataoPeriodProductPeer::getTableMap();
  73. $columns = $map->getColumns();
  74. $nameMap = array();
  75. foreach ($columns as $column) {
  76. $nameMap[$column->getPhpName()] = $column->getColumnName();
  77. }
  78. self::$phpNameMap = $nameMap;
  79. }
  80. return self::$phpNameMap;
  81. }
  82. /**
  83. * Translates a fieldname to another type
  84. *
  85. * @param string $name field name
  86. * @param string $fromType One of the class type constants TYPE_PHPNAME,
  87. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  88. * @param string $toType One of the class type constants
  89. * @return string translated name of the field.
  90. */
  91. static public function translateFieldName($name, $fromType, $toType)
  92. {
  93. $toNames = self::getFieldNames($toType);
  94. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  95. if ($key === null) {
  96. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  97. }
  98. return $toNames[$key];
  99. }
  100. /**
  101. * Returns an array of of field names.
  102. *
  103. * @param string $type The type of fieldnames to return:
  104. * One of the class type constants TYPE_PHPNAME,
  105. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  106. * @return array A list of field names
  107. */
  108. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  109. {
  110. if (!array_key_exists($type, self::$fieldNames)) {
  111. 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.');
  112. }
  113. return self::$fieldNames[$type];
  114. }
  115. /**
  116. * Convenience method which changes table.column to alias.column.
  117. *
  118. * Using this method you can maintain SQL abstraction while using column aliases.
  119. * <code>
  120. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  121. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  122. * </code>
  123. * @param string $alias The alias for the current table.
  124. * @param string $column The column name for current table. (i.e. KataoPeriodProductPeer::COLUMN_NAME).
  125. * @return string
  126. */
  127. public static function alias($alias, $column)
  128. {
  129. return str_replace(KataoPeriodProductPeer::TABLE_NAME.'.', $alias.'.', $column);
  130. }
  131. /**
  132. * Add all the columns needed to create a new object.
  133. *
  134. * Note: any columns that were marked with lazyLoad="true" in the
  135. * XML schema will not be added to the select list and only loaded
  136. * on demand.
  137. *
  138. * @param criteria object containing the columns to add.
  139. * @throws PropelException Any exceptions caught during processing will be
  140. * rethrown wrapped into a PropelException.
  141. */
  142. public static function addSelectColumns(Criteria $criteria)
  143. {
  144. $criteria->addSelectColumn(KataoPeriodProductPeer::ID);
  145. $criteria->addSelectColumn(KataoPeriodProductPeer::KATAO_PERIOD_ID);
  146. $criteria->addSelectColumn(KataoPeriodProductPeer::KATAO_PRODUCT_ID);
  147. }
  148. const COUNT = 'COUNT(katao_period_product.ID)';
  149. const COUNT_DISTINCT = 'COUNT(DISTINCT katao_period_product.ID)';
  150. /**
  151. * Returns the number of rows matching criteria.
  152. *
  153. * @param Criteria $criteria
  154. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  155. * @param Connection $con
  156. * @return int Number of matching rows.
  157. */
  158. public static function doCount(Criteria $criteria, $distinct = false, $con = null)
  159. {
  160. // we're going to modify criteria, so copy it first
  161. $criteria = clone $criteria;
  162. // clear out anything that might confuse the ORDER BY clause
  163. $criteria->clearSelectColumns()->clearOrderByColumns();
  164. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  165. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  166. } else {
  167. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  168. }
  169. // just in case we're grouping: add those columns to the select statement
  170. foreach($criteria->getGroupByColumns() as $column)
  171. {
  172. $criteria->addSelectColumn($column);
  173. }
  174. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  175. if ($rs->next()) {
  176. return $rs->getInt(1);
  177. } else {
  178. // no rows returned; we infer that means 0 matches.
  179. return 0;
  180. }
  181. }
  182. /**
  183. * Method to select one object from the DB.
  184. *
  185. * @param Criteria $criteria object used to create the SELECT statement.
  186. * @param Connection $con
  187. * @return KataoPeriodProduct
  188. * @throws PropelException Any exceptions caught during processing will be
  189. * rethrown wrapped into a PropelException.
  190. */
  191. public static function doSelectOne(Criteria $criteria, $con = null)
  192. {
  193. $critcopy = clone $criteria;
  194. $critcopy->setLimit(1);
  195. $objects = KataoPeriodProductPeer::doSelect($critcopy, $con);
  196. if ($objects) {
  197. return $objects[0];
  198. }
  199. return null;
  200. }
  201. /**
  202. * Method to do selects.
  203. *
  204. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  205. * @param Connection $con
  206. * @return array Array of selected Objects
  207. * @throws PropelException Any exceptions caught during processing will be
  208. * rethrown wrapped into a PropelException.
  209. */
  210. public static function doSelect(Criteria $criteria, $con = null)
  211. {
  212. return KataoPeriodProductPeer::populateObjects(KataoPeriodProductPeer::doSelectRS($criteria, $con));
  213. }
  214. /**
  215. * Prepares the Criteria object and uses the parent doSelect()
  216. * method to get a ResultSet.
  217. *
  218. * Use this method directly if you want to just get the resultset
  219. * (instead of an array of objects).
  220. *
  221. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  222. * @param Connection $con the connection to use
  223. * @throws PropelException Any exceptions caught during processing will be
  224. * rethrown wrapped into a PropelException.
  225. * @return ResultSet The resultset object with numerically-indexed fields.
  226. * @see BasePeer::doSelect()
  227. */
  228. public static function doSelectRS(Criteria $criteria, $con = null)
  229. {
  230. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectRS:doSelectRS') as $callable)
  231. {
  232. call_user_func($callable, 'BaseKataoPeriodProductPeer', $criteria, $con);
  233. }
  234. if ($con === null) {
  235. $con = Propel::getConnection(self::DATABASE_NAME);
  236. }
  237. if (!$criteria->getSelectColumns()) {
  238. $criteria = clone $criteria;
  239. KataoPeriodProductPeer::addSelectColumns($criteria);
  240. }
  241. // Set the correct dbName
  242. $criteria->setDbName(self::DATABASE_NAME);
  243. // BasePeer returns a Creole ResultSet, set to return
  244. // rows indexed numerically.
  245. return BasePeer::doSelect($criteria, $con);
  246. }
  247. /**
  248. * The returned array will contain objects of the default type or
  249. * objects that inherit from the default.
  250. *
  251. * @throws PropelException Any exceptions caught during processing will be
  252. * rethrown wrapped into a PropelException.
  253. */
  254. public static function populateObjects(ResultSet $rs)
  255. {
  256. $results = array();
  257. // set the class once to avoid overhead in the loop
  258. $cls = KataoPeriodProductPeer::getOMClass();
  259. $cls = sfPropel::import($cls);
  260. // populate the object(s)
  261. while($rs->next()) {
  262. $obj = new $cls();
  263. $obj->hydrate($rs);
  264. $results[] = $obj;
  265. }
  266. return $results;
  267. }
  268. /**
  269. * Returns the number of rows matching criteria, joining the related KataoPeriod table
  270. *
  271. * @param Criteria $c
  272. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  273. * @param Connection $con
  274. * @return int Number of matching rows.
  275. */
  276. public static function doCountJoinKataoPeriod(Criteria $criteria, $distinct = false, $con = null)
  277. {
  278. // we're going to modify criteria, so copy it first
  279. $criteria = clone $criteria;
  280. // clear out anything that might confuse the ORDER BY clause
  281. $criteria->clearSelectColumns()->clearOrderByColumns();
  282. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  283. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  284. } else {
  285. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  286. }
  287. // just in case we're grouping: add those columns to the select statement
  288. foreach($criteria->getGroupByColumns() as $column)
  289. {
  290. $criteria->addSelectColumn($column);
  291. }
  292. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  293. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  294. if ($rs->next()) {
  295. return $rs->getInt(1);
  296. } else {
  297. // no rows returned; we infer that means 0 matches.
  298. return 0;
  299. }
  300. }
  301. /**
  302. * Returns the number of rows matching criteria, joining the related KataoProduct table
  303. *
  304. * @param Criteria $c
  305. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  306. * @param Connection $con
  307. * @return int Number of matching rows.
  308. */
  309. public static function doCountJoinKataoProduct(Criteria $criteria, $distinct = false, $con = null)
  310. {
  311. // we're going to modify criteria, so copy it first
  312. $criteria = clone $criteria;
  313. // clear out anything that might confuse the ORDER BY clause
  314. $criteria->clearSelectColumns()->clearOrderByColumns();
  315. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  316. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  317. } else {
  318. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  319. }
  320. // just in case we're grouping: add those columns to the select statement
  321. foreach($criteria->getGroupByColumns() as $column)
  322. {
  323. $criteria->addSelectColumn($column);
  324. }
  325. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  326. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  327. if ($rs->next()) {
  328. return $rs->getInt(1);
  329. } else {
  330. // no rows returned; we infer that means 0 matches.
  331. return 0;
  332. }
  333. }
  334. /**
  335. * Selects a collection of KataoPeriodProduct objects pre-filled with their KataoPeriod objects.
  336. *
  337. * @return array Array of KataoPeriodProduct objects.
  338. * @throws PropelException Any exceptions caught during processing will be
  339. * rethrown wrapped into a PropelException.
  340. */
  341. public static function doSelectJoinKataoPeriod(Criteria $c, $con = null)
  342. {
  343. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectJoin:doSelectJoin') as $callable)
  344. {
  345. call_user_func($callable, 'BaseKataoPeriodProductPeer', $c, $con);
  346. }
  347. $c = clone $c;
  348. // Set the correct dbName if it has not been overridden
  349. if ($c->getDbName() == Propel::getDefaultDB()) {
  350. $c->setDbName(self::DATABASE_NAME);
  351. }
  352. KataoPeriodProductPeer::addSelectColumns($c);
  353. $startcol = (KataoPeriodProductPeer::NUM_COLUMNS - KataoPeriodProductPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
  354. KataoPeriodPeer::addSelectColumns($c);
  355. $c->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  356. $rs = BasePeer::doSelect($c, $con);
  357. $results = array();
  358. while($rs->next()) {
  359. $omClass = KataoPeriodProductPeer::getOMClass();
  360. $cls = sfPropel::import($omClass);
  361. $obj1 = new $cls();
  362. $obj1->hydrate($rs);
  363. $omClass = KataoPeriodPeer::getOMClass();
  364. $cls = sfPropel::import($omClass);
  365. $obj2 = new $cls();
  366. $obj2->hydrate($rs, $startcol);
  367. $newObject = true;
  368. foreach($results as $temp_obj1) {
  369. $temp_obj2 = $temp_obj1->getKataoPeriod(); //CHECKME
  370. if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
  371. $newObject = false;
  372. // e.g. $author->addBookRelatedByBookId()
  373. $temp_obj2->addKataoPeriodProduct($obj1); //CHECKME
  374. break;
  375. }
  376. }
  377. if ($newObject) {
  378. $obj2->initKataoPeriodProducts();
  379. $obj2->addKataoPeriodProduct($obj1); //CHECKME
  380. }
  381. $results[] = $obj1;
  382. }
  383. return $results;
  384. }
  385. /**
  386. * Selects a collection of KataoPeriodProduct objects pre-filled with their KataoProduct objects.
  387. *
  388. * @return array Array of KataoPeriodProduct objects.
  389. * @throws PropelException Any exceptions caught during processing will be
  390. * rethrown wrapped into a PropelException.
  391. */
  392. public static function doSelectJoinKataoProduct(Criteria $c, $con = null)
  393. {
  394. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectJoin:doSelectJoin') as $callable)
  395. {
  396. call_user_func($callable, 'BaseKataoPeriodProductPeer', $c, $con);
  397. }
  398. $c = clone $c;
  399. // Set the correct dbName if it has not been overridden
  400. if ($c->getDbName() == Propel::getDefaultDB()) {
  401. $c->setDbName(self::DATABASE_NAME);
  402. }
  403. KataoPeriodProductPeer::addSelectColumns($c);
  404. $startcol = (KataoPeriodProductPeer::NUM_COLUMNS - KataoPeriodProductPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
  405. KataoProductPeer::addSelectColumns($c);
  406. $c->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  407. $rs = BasePeer::doSelect($c, $con);
  408. $results = array();
  409. while($rs->next()) {
  410. $omClass = KataoPeriodProductPeer::getOMClass();
  411. $cls = sfPropel::import($omClass);
  412. $obj1 = new $cls();
  413. $obj1->hydrate($rs);
  414. $omClass = KataoProductPeer::getOMClass();
  415. $cls = sfPropel::import($omClass);
  416. $obj2 = new $cls();
  417. $obj2->hydrate($rs, $startcol);
  418. $newObject = true;
  419. foreach($results as $temp_obj1) {
  420. $temp_obj2 = $temp_obj1->getKataoProduct(); //CHECKME
  421. if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
  422. $newObject = false;
  423. // e.g. $author->addBookRelatedByBookId()
  424. $temp_obj2->addKataoPeriodProduct($obj1); //CHECKME
  425. break;
  426. }
  427. }
  428. if ($newObject) {
  429. $obj2->initKataoPeriodProducts();
  430. $obj2->addKataoPeriodProduct($obj1); //CHECKME
  431. }
  432. $results[] = $obj1;
  433. }
  434. return $results;
  435. }
  436. /**
  437. * Returns the number of rows matching criteria, joining all related tables
  438. *
  439. * @param Criteria $c
  440. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  441. * @param Connection $con
  442. * @return int Number of matching rows.
  443. */
  444. public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
  445. {
  446. $criteria = clone $criteria;
  447. // clear out anything that might confuse the ORDER BY clause
  448. $criteria->clearSelectColumns()->clearOrderByColumns();
  449. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  450. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  451. } else {
  452. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  453. }
  454. // just in case we're grouping: add those columns to the select statement
  455. foreach($criteria->getGroupByColumns() as $column)
  456. {
  457. $criteria->addSelectColumn($column);
  458. }
  459. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  460. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  461. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  462. if ($rs->next()) {
  463. return $rs->getInt(1);
  464. } else {
  465. // no rows returned; we infer that means 0 matches.
  466. return 0;
  467. }
  468. }
  469. /**
  470. * Selects a collection of KataoPeriodProduct objects pre-filled with all related objects.
  471. *
  472. * @return array Array of KataoPeriodProduct objects.
  473. * @throws PropelException Any exceptions caught during processing will be
  474. * rethrown wrapped into a PropelException.
  475. */
  476. public static function doSelectJoinAll(Criteria $c, $con = null)
  477. {
  478. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectJoinAll:doSelectJoinAll') as $callable)
  479. {
  480. call_user_func($callable, 'BaseKataoPeriodProductPeer', $c, $con);
  481. }
  482. $c = clone $c;
  483. // Set the correct dbName if it has not been overridden
  484. if ($c->getDbName() == Propel::getDefaultDB()) {
  485. $c->setDbName(self::DATABASE_NAME);
  486. }
  487. KataoPeriodProductPeer::addSelectColumns($c);
  488. $startcol2 = (KataoPeriodProductPeer::NUM_COLUMNS - KataoPeriodProductPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
  489. KataoPeriodPeer::addSelectColumns($c);
  490. $startcol3 = $startcol2 + KataoPeriodPeer::NUM_COLUMNS;
  491. KataoProductPeer::addSelectColumns($c);
  492. $startcol4 = $startcol3 + KataoProductPeer::NUM_COLUMNS;
  493. $c->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  494. $c->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  495. $rs = BasePeer::doSelect($c, $con);
  496. $results = array();
  497. while($rs->next()) {
  498. $omClass = KataoPeriodProductPeer::getOMClass();
  499. $cls = sfPropel::import($omClass);
  500. $obj1 = new $cls();
  501. $obj1->hydrate($rs);
  502. // Add objects for joined KataoPeriod rows
  503. $omClass = KataoPeriodPeer::getOMClass();
  504. $cls = sfPropel::import($omClass);
  505. $obj2 = new $cls();
  506. $obj2->hydrate($rs, $startcol2);
  507. $newObject = true;
  508. for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
  509. $temp_obj1 = $results[$j];
  510. $temp_obj2 = $temp_obj1->getKataoPeriod(); // CHECKME
  511. if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
  512. $newObject = false;
  513. $temp_obj2->addKataoPeriodProduct($obj1); // CHECKME
  514. break;
  515. }
  516. }
  517. if ($newObject) {
  518. $obj2->initKataoPeriodProducts();
  519. $obj2->addKataoPeriodProduct($obj1);
  520. }
  521. // Add objects for joined KataoProduct rows
  522. $omClass = KataoProductPeer::getOMClass();
  523. $cls = sfPropel::import($omClass);
  524. $obj3 = new $cls();
  525. $obj3->hydrate($rs, $startcol3);
  526. $newObject = true;
  527. for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
  528. $temp_obj1 = $results[$j];
  529. $temp_obj3 = $temp_obj1->getKataoProduct(); // CHECKME
  530. if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
  531. $newObject = false;
  532. $temp_obj3->addKataoPeriodProduct($obj1); // CHECKME
  533. break;
  534. }
  535. }
  536. if ($newObject) {
  537. $obj3->initKataoPeriodProducts();
  538. $obj3->addKataoPeriodProduct($obj1);
  539. }
  540. $results[] = $obj1;
  541. }
  542. return $results;
  543. }
  544. /**
  545. * Returns the number of rows matching criteria, joining the related KataoPeriod table
  546. *
  547. * @param Criteria $c
  548. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  549. * @param Connection $con
  550. * @return int Number of matching rows.
  551. */
  552. public static function doCountJoinAllExceptKataoPeriod(Criteria $criteria, $distinct = false, $con = null)
  553. {
  554. // we're going to modify criteria, so copy it first
  555. $criteria = clone $criteria;
  556. // clear out anything that might confuse the ORDER BY clause
  557. $criteria->clearSelectColumns()->clearOrderByColumns();
  558. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  559. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  560. } else {
  561. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  562. }
  563. // just in case we're grouping: add those columns to the select statement
  564. foreach($criteria->getGroupByColumns() as $column)
  565. {
  566. $criteria->addSelectColumn($column);
  567. }
  568. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  569. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  570. if ($rs->next()) {
  571. return $rs->getInt(1);
  572. } else {
  573. // no rows returned; we infer that means 0 matches.
  574. return 0;
  575. }
  576. }
  577. /**
  578. * Returns the number of rows matching criteria, joining the related KataoProduct table
  579. *
  580. * @param Criteria $c
  581. * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  582. * @param Connection $con
  583. * @return int Number of matching rows.
  584. */
  585. public static function doCountJoinAllExceptKataoProduct(Criteria $criteria, $distinct = false, $con = null)
  586. {
  587. // we're going to modify criteria, so copy it first
  588. $criteria = clone $criteria;
  589. // clear out anything that might confuse the ORDER BY clause
  590. $criteria->clearSelectColumns()->clearOrderByColumns();
  591. if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  592. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT_DISTINCT);
  593. } else {
  594. $criteria->addSelectColumn(KataoPeriodProductPeer::COUNT);
  595. }
  596. // just in case we're grouping: add those columns to the select statement
  597. foreach($criteria->getGroupByColumns() as $column)
  598. {
  599. $criteria->addSelectColumn($column);
  600. }
  601. $criteria->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  602. $rs = KataoPeriodProductPeer::doSelectRS($criteria, $con);
  603. if ($rs->next()) {
  604. return $rs->getInt(1);
  605. } else {
  606. // no rows returned; we infer that means 0 matches.
  607. return 0;
  608. }
  609. }
  610. /**
  611. * Selects a collection of KataoPeriodProduct objects pre-filled with all related objects except KataoPeriod.
  612. *
  613. * @return array Array of KataoPeriodProduct objects.
  614. * @throws PropelException Any exceptions caught during processing will be
  615. * rethrown wrapped into a PropelException.
  616. */
  617. public static function doSelectJoinAllExceptKataoPeriod(Criteria $c, $con = null)
  618. {
  619. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable)
  620. {
  621. call_user_func($callable, 'BaseKataoPeriodProductPeer', $c, $con);
  622. }
  623. $c = clone $c;
  624. // Set the correct dbName if it has not been overridden
  625. // $c->getDbName() will return the same object if not set to another value
  626. // so == check is okay and faster
  627. if ($c->getDbName() == Propel::getDefaultDB()) {
  628. $c->setDbName(self::DATABASE_NAME);
  629. }
  630. KataoPeriodProductPeer::addSelectColumns($c);
  631. $startcol2 = (KataoPeriodProductPeer::NUM_COLUMNS - KataoPeriodProductPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
  632. KataoProductPeer::addSelectColumns($c);
  633. $startcol3 = $startcol2 + KataoProductPeer::NUM_COLUMNS;
  634. $c->addJoin(KataoPeriodProductPeer::KATAO_PRODUCT_ID, KataoProductPeer::ID);
  635. $rs = BasePeer::doSelect($c, $con);
  636. $results = array();
  637. while($rs->next()) {
  638. $omClass = KataoPeriodProductPeer::getOMClass();
  639. $cls = sfPropel::import($omClass);
  640. $obj1 = new $cls();
  641. $obj1->hydrate($rs);
  642. $omClass = KataoProductPeer::getOMClass();
  643. $cls = sfPropel::import($omClass);
  644. $obj2 = new $cls();
  645. $obj2->hydrate($rs, $startcol2);
  646. $newObject = true;
  647. for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
  648. $temp_obj1 = $results[$j];
  649. $temp_obj2 = $temp_obj1->getKataoProduct(); //CHECKME
  650. if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
  651. $newObject = false;
  652. $temp_obj2->addKataoPeriodProduct($obj1);
  653. break;
  654. }
  655. }
  656. if ($newObject) {
  657. $obj2->initKataoPeriodProducts();
  658. $obj2->addKataoPeriodProduct($obj1);
  659. }
  660. $results[] = $obj1;
  661. }
  662. return $results;
  663. }
  664. /**
  665. * Selects a collection of KataoPeriodProduct objects pre-filled with all related objects except KataoProduct.
  666. *
  667. * @return array Array of KataoPeriodProduct objects.
  668. * @throws PropelException Any exceptions caught during processing will be
  669. * rethrown wrapped into a PropelException.
  670. */
  671. public static function doSelectJoinAllExceptKataoProduct(Criteria $c, $con = null)
  672. {
  673. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable)
  674. {
  675. call_user_func($callable, 'BaseKataoPeriodProductPeer', $c, $con);
  676. }
  677. $c = clone $c;
  678. // Set the correct dbName if it has not been overridden
  679. // $c->getDbName() will return the same object if not set to another value
  680. // so == check is okay and faster
  681. if ($c->getDbName() == Propel::getDefaultDB()) {
  682. $c->setDbName(self::DATABASE_NAME);
  683. }
  684. KataoPeriodProductPeer::addSelectColumns($c);
  685. $startcol2 = (KataoPeriodProductPeer::NUM_COLUMNS - KataoPeriodProductPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
  686. KataoPeriodPeer::addSelectColumns($c);
  687. $startcol3 = $startcol2 + KataoPeriodPeer::NUM_COLUMNS;
  688. $c->addJoin(KataoPeriodProductPeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
  689. $rs = BasePeer::doSelect($c, $con);
  690. $results = array();
  691. while($rs->next()) {
  692. $omClass = KataoPeriodProductPeer::getOMClass();
  693. $cls = sfPropel::import($omClass);
  694. $obj1 = new $cls();
  695. $obj1->hydrate($rs);
  696. $omClass = KataoPeriodPeer::getOMClass();
  697. $cls = sfPropel::import($omClass);
  698. $obj2 = new $cls();
  699. $obj2->hydrate($rs, $startcol2);
  700. $newObject = true;
  701. for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
  702. $temp_obj1 = $results[$j];
  703. $temp_obj2 = $temp_obj1->getKataoPeriod(); //CHECKME
  704. if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
  705. $newObject = false;
  706. $temp_obj2->addKataoPeriodProduct($obj1);
  707. break;
  708. }
  709. }
  710. if ($newObject) {
  711. $obj2->initKataoPeriodProducts();
  712. $obj2->addKataoPeriodProduct($obj1);
  713. }
  714. $results[] = $obj1;
  715. }
  716. return $results;
  717. }
  718. static public function getUniqueColumnNames()
  719. {
  720. return array();
  721. }
  722. /**
  723. * Returns the TableMap related to this peer.
  724. * This method is not needed for general use but a specific application could have a need.
  725. * @return TableMap
  726. * @throws PropelException Any exceptions caught during processing will be
  727. * rethrown wrapped into a PropelException.
  728. */
  729. public static function getTableMap()
  730. {
  731. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  732. }
  733. /**
  734. * The class that the Peer will make instances of.
  735. *
  736. * This uses a dot-path notation which is tranalted into a path
  737. * relative to a location on the PHP include_path.
  738. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  739. *
  740. * @return string path.to.ClassName
  741. */
  742. public static function getOMClass()
  743. {
  744. return KataoPeriodProductPeer::CLASS_DEFAULT;
  745. }
  746. /**
  747. * Method perform an INSERT on the database, given a KataoPeriodProduct or Criteria object.
  748. *
  749. * @param mixed $values Criteria or KataoPeriodProduct object containing data that is used to create the INSERT statement.
  750. * @param Connection $con the connection to use
  751. * @return mixed The new primary key.
  752. * @throws PropelException Any exceptions caught during processing will be
  753. * rethrown wrapped into a PropelException.
  754. */
  755. public static function doInsert($values, $con = null)
  756. {
  757. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doInsert:pre') as $callable)
  758. {
  759. $ret = call_user_func($callable, 'BaseKataoPeriodProductPeer', $values, $con);
  760. if (false !== $ret)
  761. {
  762. return $ret;
  763. }
  764. }
  765. if ($con === null) {
  766. $con = Propel::getConnection(self::DATABASE_NAME);
  767. }
  768. if ($values instanceof Criteria) {
  769. $criteria = clone $values; // rename for clarity
  770. } else {
  771. $criteria = $values->buildCriteria(); // build Criteria from KataoPeriodProduct object
  772. }
  773. $criteria->remove(KataoPeriodProductPeer::ID); // remove pkey col since this table uses auto-increment
  774. // Set the correct dbName
  775. $criteria->setDbName(self::DATABASE_NAME);
  776. try {
  777. // use transaction because $criteria could contain info
  778. // for more than one table (I guess, conceivably)
  779. $con->begin();
  780. $pk = BasePeer::doInsert($criteria, $con);
  781. $con->commit();
  782. } catch(PropelException $e) {
  783. $con->rollback();
  784. throw $e;
  785. }
  786. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doInsert:post') as $callable)
  787. {
  788. call_user_func($callable, 'BaseKataoPeriodProductPeer', $values, $con, $pk);
  789. }
  790. return $pk;
  791. }
  792. /**
  793. * Method perform an UPDATE on the database, given a KataoPeriodProduct or Criteria object.
  794. *
  795. * @param mixed $values Criteria or KataoPeriodProduct object containing data that is used to create the UPDATE statement.
  796. * @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
  797. * @return int The number of affected rows (if supported by underlying database driver).
  798. * @throws PropelException Any exceptions caught during processing will be
  799. * rethrown wrapped into a PropelException.
  800. */
  801. public static function doUpdate($values, $con = null)
  802. {
  803. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doUpdate:pre') as $callable)
  804. {
  805. $ret = call_user_func($callable, 'BaseKataoPeriodProductPeer', $values, $con);
  806. if (false !== $ret)
  807. {
  808. return $ret;
  809. }
  810. }
  811. if ($con === null) {
  812. $con = Propel::getConnection(self::DATABASE_NAME);
  813. }
  814. $selectCriteria = new Criteria(self::DATABASE_NAME);
  815. if ($values instanceof Criteria) {
  816. $criteria = clone $values; // rename for clarity
  817. $comparison = $criteria->getComparison(KataoPeriodProductPeer::ID);
  818. $selectCriteria->add(KataoPeriodProductPeer::ID, $criteria->remove(KataoPeriodProductPeer::ID), $comparison);
  819. } else { // $values is KataoPeriodProduct object
  820. $criteria = $values->buildCriteria(); // gets full criteria
  821. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  822. }
  823. // set the correct dbName
  824. $criteria->setDbName(self::DATABASE_NAME);
  825. $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
  826. foreach (sfMixer::getCallables('BaseKataoPeriodProductPeer:doUpdate:post') as $callable)
  827. {
  828. call_user_func($callable, 'BaseKataoPeriodProductPeer', $values, $con, $ret);
  829. }
  830. return $ret;
  831. }
  832. /**
  833. * Method to DELETE all rows from the katao_period_product table.
  834. *
  835. * @return int The number of affected rows (if supported by underlying database driver).
  836. */
  837. public static function doDeleteAll($con = null)
  838. {
  839. if ($con === null) {
  840. $con = Propel::getConnection(self::DATABASE_NAME);
  841. }
  842. $affectedRows = 0; // initialize var to track total num of affected rows
  843. try {
  844. // use transaction because $criteria could contain info
  845. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  846. $con->begin();
  847. $affectedRows += BasePeer::doDeleteAll(KataoPeriodProductPeer::TABLE_NAME, $con);
  848. $con->commit();
  849. return $affectedRows;
  850. } catch (PropelException $e) {
  851. $con->rollback();
  852. throw $e;
  853. }
  854. }
  855. /**
  856. * Method perform a DELETE on the database, given a KataoPeriodProduct or Criteria object OR a primary key value.
  857. *
  858. * @param mixed $values Criteria or KataoPeriodProduct object or primary key or array of primary keys
  859. * which is used to create the DELETE statement
  860. * @param Connection $con the connection to use
  861. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  862. * if supported by native driver or if emulated using Propel.
  863. * @throws PropelException Any exceptions caught during processing will be
  864. * rethrown wrapped into a PropelException.
  865. */
  866. public static function doDelete($values, $con = null)
  867. {
  868. if ($con === null) {
  869. $con = Propel::getConnection(KataoPeriodProductPeer::DATABASE_NAME);
  870. }
  871. if ($values instanceof Criteria) {
  872. $criteria = clone $values; // rename for clarity
  873. } elseif ($values instanceof KataoPeriodProduct) {
  874. $criteria = $values->buildPkeyCriteria();
  875. } else {
  876. // it must be the primary key
  877. $criteria = new Criteria(self::DATABASE_NAME);
  878. $criteria->add(KataoPeriodProductPeer::ID, (array) $values, Criteria::IN);
  879. }
  880. // Set the correct dbName
  881. $criteria->setDbName(self::DATABASE_NAME);
  882. $affectedRows = 0; // initialize var to track total num of affected rows
  883. try {
  884. // use transaction because $criteria could contain info
  885. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  886. $con->begin();
  887. $affectedRows += BasePeer::doDelete($criteria, $con);
  888. $con->commit();
  889. return $affectedRows;
  890. } catch (PropelException $e) {
  891. $con->rollback();
  892. throw $e;
  893. }
  894. }
  895. /**
  896. * Validates all modified columns of given KataoPeriodProduct object.
  897. * If parameter $columns is either a single column name or an array of column names
  898. * than only those columns are validated.
  899. *
  900. * NOTICE: This does not apply to primary or foreign keys for now.
  901. *
  902. * @param KataoPeriodProduct $obj The object to validate.
  903. * @param mixed $cols Column name or array of column names.
  904. *
  905. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  906. */
  907. public static function doValidate(KataoPeriodProduct $obj, $cols = null)
  908. {
  909. $columns = array();
  910. if ($cols) {
  911. $dbMap = Propel::getDatabaseMap(KataoPeriodProductPeer::DATABASE_NAME);
  912. $tableMap = $dbMap->getTable(KataoPeriodProductPeer::TABLE_NAME);
  913. if (! is_array($cols)) {
  914. $cols = array($cols);
  915. }
  916. foreach($cols as $colName) {
  917. if ($tableMap->containsColumn($colName)) {
  918. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  919. $columns[$colName] = $obj->$get();
  920. }
  921. }
  922. } else {
  923. }
  924. $res = BasePeer::doValidate(KataoPeriodProductPeer::DATABASE_NAME, KataoPeriodProductPeer::TABLE_NAME, $columns);
  925. if ($res !== true) {
  926. $request = sfContext::getInstance()->getRequest();
  927. foreach ($res as $failed) {
  928. $col = KataoPeriodProductPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
  929. $request->setError($col, $failed->getMessage());
  930. }
  931. }
  932. return $res;
  933. }
  934. /**
  935. * Retrieve a single object by pkey.
  936. *
  937. * @param mixed $pk the primary key.
  938. * @param Connection $con the connection to use
  939. * @return KataoPeriodProduct
  940. */
  941. public static function retrieveByPK($pk, $con = null)
  942. {
  943. if ($con === null) {
  944. $con = Propel::getConnection(self::DATABASE_NAME);
  945. }
  946. $criteria = new Criteria(KataoPeriodProductPeer::DATABASE_NAME);
  947. $criteria->add(KataoPeriodProductPeer::ID, $pk);
  948. $v = KataoPeriodProductPeer::doSelect($criteria, $con);
  949. return !empty($v) > 0 ? $v[0] : null;
  950. }
  951. /**
  952. * Retrieve multiple objects by pkey.
  953. *
  954. * @param array $pks List of primary keys
  955. * @param Connection $con the connection to use
  956. * @throws PropelException Any exceptions caught during processing will be
  957. * rethrown wrapped into a PropelException.
  958. */
  959. public static function retrieveByPKs($pks, $con = null)
  960. {
  961. if ($con === null) {
  962. $con = Propel::getConnection(self::DATABASE_NAME);
  963. }
  964. $objs = null;
  965. if (empty($pks)) {
  966. $objs = array();
  967. } else {
  968. $criteria = new Criteria();
  969. $criteria->add(KataoPeriodProductPeer::ID, $pks, Criteria::IN);
  970. $objs = KataoPeriodProductPeer::doSelect($criteria, $con);
  971. }
  972. return $objs;
  973. }
  974. } // BaseKataoPeriodProductPeer
  975. // static code to register the map builder for this Peer with the main Propel class
  976. if (Propel::isInit()) {
  977. // the MapBuilder classes register themselves with Propel during initialization
  978. // so we need to load them here.
  979. try {
  980. BaseKataoPeriodProductPeer::getMapBuilder();
  981. } catch (Exception $e) {
  982. Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
  983. }
  984. } else {
  985. // even if Propel is not yet initialized, the map builder class can be registered
  986. // now and then it will be loaded when Propel initializes.
  987. Propel::registerMapBuilder('lib.model.map.KataoPeriodProductMapBuilder');
  988. }