BaseKataoProductFamilyPeer.php 28 KB

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