BaseKataoSupplierPeer.php 41 KB

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