BaseKataoOrderProductPeer.php 41 KB

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