BaseKataoProductPeer.php 42 KB

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