BaseKataoNodePeer.php 26 KB

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