BaseCcSubjsPeer.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'cc_subjs' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcSubjsPeer {
  10. /** the default database name for this class */
  11. const DATABASE_NAME = 'airtime';
  12. /** the table name for this class */
  13. const TABLE_NAME = 'cc_subjs';
  14. /** the related Propel class for this table */
  15. const OM_CLASS = 'CcSubjs';
  16. /** A class that can be returned by this peer. */
  17. const CLASS_DEFAULT = 'airtime.CcSubjs';
  18. /** the related TableMap class for this table */
  19. const TM_CLASS = 'CcSubjsTableMap';
  20. /** The total number of columns. */
  21. const NUM_COLUMNS = 13;
  22. /** The number of lazy-loaded columns. */
  23. const NUM_LAZY_LOAD_COLUMNS = 0;
  24. /** the column name for the ID field */
  25. const ID = 'cc_subjs.ID';
  26. /** the column name for the LOGIN field */
  27. const LOGIN = 'cc_subjs.LOGIN';
  28. /** the column name for the PASS field */
  29. const PASS = 'cc_subjs.PASS';
  30. /** the column name for the TYPE field */
  31. const TYPE = 'cc_subjs.TYPE';
  32. /** the column name for the FIRST_NAME field */
  33. const FIRST_NAME = 'cc_subjs.FIRST_NAME';
  34. /** the column name for the LAST_NAME field */
  35. const LAST_NAME = 'cc_subjs.LAST_NAME';
  36. /** the column name for the LASTLOGIN field */
  37. const LASTLOGIN = 'cc_subjs.LASTLOGIN';
  38. /** the column name for the LASTFAIL field */
  39. const LASTFAIL = 'cc_subjs.LASTFAIL';
  40. /** the column name for the SKYPE_CONTACT field */
  41. const SKYPE_CONTACT = 'cc_subjs.SKYPE_CONTACT';
  42. /** the column name for the JABBER_CONTACT field */
  43. const JABBER_CONTACT = 'cc_subjs.JABBER_CONTACT';
  44. /** the column name for the EMAIL field */
  45. const EMAIL = 'cc_subjs.EMAIL';
  46. /** the column name for the CELL_PHONE field */
  47. const CELL_PHONE = 'cc_subjs.CELL_PHONE';
  48. /** the column name for the LOGIN_ATTEMPTS field */
  49. const LOGIN_ATTEMPTS = 'cc_subjs.LOGIN_ATTEMPTS';
  50. /**
  51. * An identiy map to hold any loaded instances of CcSubjs objects.
  52. * This must be public so that other peer classes can access this when hydrating from JOIN
  53. * queries.
  54. * @var array CcSubjs[]
  55. */
  56. public static $instances = array();
  57. /**
  58. * holds an array of fieldnames
  59. *
  60. * first dimension keys are the type constants
  61. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  62. */
  63. private static $fieldNames = array (
  64. BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLogin', 'DbPass', 'DbType', 'DbFirstName', 'DbLastName', 'DbLastlogin', 'DbLastfail', 'DbSkypeContact', 'DbJabberContact', 'DbEmail', 'DbCellPhone', 'DbLoginAttempts', ),
  65. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLogin', 'dbPass', 'dbType', 'dbFirstName', 'dbLastName', 'dbLastlogin', 'dbLastfail', 'dbSkypeContact', 'dbJabberContact', 'dbEmail', 'dbCellPhone', 'dbLoginAttempts', ),
  66. BasePeer::TYPE_COLNAME => array (self::ID, self::LOGIN, self::PASS, self::TYPE, self::FIRST_NAME, self::LAST_NAME, self::LASTLOGIN, self::LASTFAIL, self::SKYPE_CONTACT, self::JABBER_CONTACT, self::EMAIL, self::CELL_PHONE, self::LOGIN_ATTEMPTS, ),
  67. BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'FIRST_NAME', 'LAST_NAME', 'LASTLOGIN', 'LASTFAIL', 'SKYPE_CONTACT', 'JABBER_CONTACT', 'EMAIL', 'CELL_PHONE', 'LOGIN_ATTEMPTS', ),
  68. BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'first_name', 'last_name', 'lastlogin', 'lastfail', 'skype_contact', 'jabber_contact', 'email', 'cell_phone', 'login_attempts', ),
  69. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
  70. );
  71. /**
  72. * holds an array of keys for quick access to the fieldnames array
  73. *
  74. * first dimension keys are the type constants
  75. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  76. */
  77. private static $fieldKeys = array (
  78. BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLogin' => 1, 'DbPass' => 2, 'DbType' => 3, 'DbFirstName' => 4, 'DbLastName' => 5, 'DbLastlogin' => 6, 'DbLastfail' => 7, 'DbSkypeContact' => 8, 'DbJabberContact' => 9, 'DbEmail' => 10, 'DbCellPhone' => 11, 'DbLoginAttempts' => 12, ),
  79. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLogin' => 1, 'dbPass' => 2, 'dbType' => 3, 'dbFirstName' => 4, 'dbLastName' => 5, 'dbLastlogin' => 6, 'dbLastfail' => 7, 'dbSkypeContact' => 8, 'dbJabberContact' => 9, 'dbEmail' => 10, 'dbCellPhone' => 11, 'dbLoginAttempts' => 12, ),
  80. BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOGIN => 1, self::PASS => 2, self::TYPE => 3, self::FIRST_NAME => 4, self::LAST_NAME => 5, self::LASTLOGIN => 6, self::LASTFAIL => 7, self::SKYPE_CONTACT => 8, self::JABBER_CONTACT => 9, self::EMAIL => 10, self::CELL_PHONE => 11, self::LOGIN_ATTEMPTS => 12, ),
  81. BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'FIRST_NAME' => 4, 'LAST_NAME' => 5, 'LASTLOGIN' => 6, 'LASTFAIL' => 7, 'SKYPE_CONTACT' => 8, 'JABBER_CONTACT' => 9, 'EMAIL' => 10, 'CELL_PHONE' => 11, 'LOGIN_ATTEMPTS' => 12, ),
  82. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'first_name' => 4, 'last_name' => 5, 'lastlogin' => 6, 'lastfail' => 7, 'skype_contact' => 8, 'jabber_contact' => 9, 'email' => 10, 'cell_phone' => 11, 'login_attempts' => 12, ),
  83. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
  84. );
  85. /**
  86. * Translates a fieldname to another type
  87. *
  88. * @param string $name field name
  89. * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  90. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  91. * @param string $toType One of the class type constants
  92. * @return string translated name of the field.
  93. * @throws PropelException - if the specified name could not be found in the fieldname mappings.
  94. */
  95. static public function translateFieldName($name, $fromType, $toType)
  96. {
  97. $toNames = self::getFieldNames($toType);
  98. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  99. if ($key === null) {
  100. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  101. }
  102. return $toNames[$key];
  103. }
  104. /**
  105. * Returns an array of field names.
  106. *
  107. * @param string $type The type of fieldnames to return:
  108. * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  109. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  110. * @return array A list of field names
  111. */
  112. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  113. {
  114. if (!array_key_exists($type, self::$fieldNames)) {
  115. throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
  116. }
  117. return self::$fieldNames[$type];
  118. }
  119. /**
  120. * Convenience method which changes table.column to alias.column.
  121. *
  122. * Using this method you can maintain SQL abstraction while using column aliases.
  123. * <code>
  124. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  125. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  126. * </code>
  127. * @param string $alias The alias for the current table.
  128. * @param string $column The column name for current table. (i.e. CcSubjsPeer::COLUMN_NAME).
  129. * @return string
  130. */
  131. public static function alias($alias, $column)
  132. {
  133. return str_replace(CcSubjsPeer::TABLE_NAME.'.', $alias.'.', $column);
  134. }
  135. /**
  136. * Add all the columns needed to create a new object.
  137. *
  138. * Note: any columns that were marked with lazyLoad="true" in the
  139. * XML schema will not be added to the select list and only loaded
  140. * on demand.
  141. *
  142. * @param Criteria $criteria object containing the columns to add.
  143. * @param string $alias optional table alias
  144. * @throws PropelException Any exceptions caught during processing will be
  145. * rethrown wrapped into a PropelException.
  146. */
  147. public static function addSelectColumns(Criteria $criteria, $alias = null)
  148. {
  149. if (null === $alias) {
  150. $criteria->addSelectColumn(CcSubjsPeer::ID);
  151. $criteria->addSelectColumn(CcSubjsPeer::LOGIN);
  152. $criteria->addSelectColumn(CcSubjsPeer::PASS);
  153. $criteria->addSelectColumn(CcSubjsPeer::TYPE);
  154. $criteria->addSelectColumn(CcSubjsPeer::FIRST_NAME);
  155. $criteria->addSelectColumn(CcSubjsPeer::LAST_NAME);
  156. $criteria->addSelectColumn(CcSubjsPeer::LASTLOGIN);
  157. $criteria->addSelectColumn(CcSubjsPeer::LASTFAIL);
  158. $criteria->addSelectColumn(CcSubjsPeer::SKYPE_CONTACT);
  159. $criteria->addSelectColumn(CcSubjsPeer::JABBER_CONTACT);
  160. $criteria->addSelectColumn(CcSubjsPeer::EMAIL);
  161. $criteria->addSelectColumn(CcSubjsPeer::CELL_PHONE);
  162. $criteria->addSelectColumn(CcSubjsPeer::LOGIN_ATTEMPTS);
  163. } else {
  164. $criteria->addSelectColumn($alias . '.ID');
  165. $criteria->addSelectColumn($alias . '.LOGIN');
  166. $criteria->addSelectColumn($alias . '.PASS');
  167. $criteria->addSelectColumn($alias . '.TYPE');
  168. $criteria->addSelectColumn($alias . '.FIRST_NAME');
  169. $criteria->addSelectColumn($alias . '.LAST_NAME');
  170. $criteria->addSelectColumn($alias . '.LASTLOGIN');
  171. $criteria->addSelectColumn($alias . '.LASTFAIL');
  172. $criteria->addSelectColumn($alias . '.SKYPE_CONTACT');
  173. $criteria->addSelectColumn($alias . '.JABBER_CONTACT');
  174. $criteria->addSelectColumn($alias . '.EMAIL');
  175. $criteria->addSelectColumn($alias . '.CELL_PHONE');
  176. $criteria->addSelectColumn($alias . '.LOGIN_ATTEMPTS');
  177. }
  178. }
  179. /**
  180. * Returns the number of rows matching criteria.
  181. *
  182. * @param Criteria $criteria
  183. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  184. * @param PropelPDO $con
  185. * @return int Number of matching rows.
  186. */
  187. public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
  188. {
  189. // we may modify criteria, so copy it first
  190. $criteria = clone $criteria;
  191. // We need to set the primary table name, since in the case that there are no WHERE columns
  192. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  193. // tables go into the FROM clause.
  194. $criteria->setPrimaryTableName(CcSubjsPeer::TABLE_NAME);
  195. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  196. $criteria->setDistinct();
  197. }
  198. if (!$criteria->hasSelectClause()) {
  199. CcSubjsPeer::addSelectColumns($criteria);
  200. }
  201. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  202. $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
  203. if ($con === null) {
  204. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  205. }
  206. // BasePeer returns a PDOStatement
  207. $stmt = BasePeer::doCount($criteria, $con);
  208. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  209. $count = (int) $row[0];
  210. } else {
  211. $count = 0; // no rows returned; we infer that means 0 matches.
  212. }
  213. $stmt->closeCursor();
  214. return $count;
  215. }
  216. /**
  217. * Method to select one object from the DB.
  218. *
  219. * @param Criteria $criteria object used to create the SELECT statement.
  220. * @param PropelPDO $con
  221. * @return CcSubjs
  222. * @throws PropelException Any exceptions caught during processing will be
  223. * rethrown wrapped into a PropelException.
  224. */
  225. public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
  226. {
  227. $critcopy = clone $criteria;
  228. $critcopy->setLimit(1);
  229. $objects = CcSubjsPeer::doSelect($critcopy, $con);
  230. if ($objects) {
  231. return $objects[0];
  232. }
  233. return null;
  234. }
  235. /**
  236. * Method to do selects.
  237. *
  238. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  239. * @param PropelPDO $con
  240. * @return array Array of selected Objects
  241. * @throws PropelException Any exceptions caught during processing will be
  242. * rethrown wrapped into a PropelException.
  243. */
  244. public static function doSelect(Criteria $criteria, PropelPDO $con = null)
  245. {
  246. return CcSubjsPeer::populateObjects(CcSubjsPeer::doSelectStmt($criteria, $con));
  247. }
  248. /**
  249. * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  250. *
  251. * Use this method directly if you want to work with an executed statement durirectly (for example
  252. * to perform your own object hydration).
  253. *
  254. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  255. * @param PropelPDO $con The connection to use
  256. * @throws PropelException Any exceptions caught during processing will be
  257. * rethrown wrapped into a PropelException.
  258. * @return PDOStatement The executed PDOStatement object.
  259. * @see BasePeer::doSelect()
  260. */
  261. public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
  262. {
  263. if ($con === null) {
  264. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  265. }
  266. if (!$criteria->hasSelectClause()) {
  267. $criteria = clone $criteria;
  268. CcSubjsPeer::addSelectColumns($criteria);
  269. }
  270. // Set the correct dbName
  271. $criteria->setDbName(self::DATABASE_NAME);
  272. // BasePeer returns a PDOStatement
  273. return BasePeer::doSelect($criteria, $con);
  274. }
  275. /**
  276. * Adds an object to the instance pool.
  277. *
  278. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  279. * from the database. In some cases -- especially when you override doSelect*()
  280. * methods in your stub classes -- you may need to explicitly add objects
  281. * to the cache in order to ensure that the same objects are always returned by doSelect*()
  282. * and retrieveByPK*() calls.
  283. *
  284. * @param CcSubjs $value A CcSubjs object.
  285. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  286. */
  287. public static function addInstanceToPool(CcSubjs $obj, $key = null)
  288. {
  289. if (Propel::isInstancePoolingEnabled()) {
  290. if ($key === null) {
  291. $key = (string) $obj->getDbId();
  292. } // if key === null
  293. self::$instances[$key] = $obj;
  294. }
  295. }
  296. /**
  297. * Removes an object from the instance pool.
  298. *
  299. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  300. * from the database. In some cases -- especially when you override doDelete
  301. * methods in your stub classes -- you may need to explicitly remove objects
  302. * from the cache in order to prevent returning objects that no longer exist.
  303. *
  304. * @param mixed $value A CcSubjs object or a primary key value.
  305. */
  306. public static function removeInstanceFromPool($value)
  307. {
  308. if (Propel::isInstancePoolingEnabled() && $value !== null) {
  309. if (is_object($value) && $value instanceof CcSubjs) {
  310. $key = (string) $value->getDbId();
  311. } elseif (is_scalar($value)) {
  312. // assume we've been passed a primary key
  313. $key = (string) $value;
  314. } else {
  315. $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcSubjs object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
  316. throw $e;
  317. }
  318. unset(self::$instances[$key]);
  319. }
  320. } // removeInstanceFromPool()
  321. /**
  322. * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
  323. *
  324. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  325. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  326. *
  327. * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
  328. * @return CcSubjs Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  329. * @see getPrimaryKeyHash()
  330. */
  331. public static function getInstanceFromPool($key)
  332. {
  333. if (Propel::isInstancePoolingEnabled()) {
  334. if (isset(self::$instances[$key])) {
  335. return self::$instances[$key];
  336. }
  337. }
  338. return null; // just to be explicit
  339. }
  340. /**
  341. * Clear the instance pool.
  342. *
  343. * @return void
  344. */
  345. public static function clearInstancePool()
  346. {
  347. self::$instances = array();
  348. }
  349. /**
  350. * Method to invalidate the instance pool of all tables related to cc_subjs
  351. * by a foreign key with ON DELETE CASCADE
  352. */
  353. public static function clearRelatedInstancePool()
  354. {
  355. // Invalidate objects in CcPermsPeer instance pool,
  356. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  357. CcPermsPeer::clearInstancePool();
  358. // Invalidate objects in CcShowHostsPeer instance pool,
  359. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  360. CcShowHostsPeer::clearInstancePool();
  361. // Invalidate objects in CcPlaylistPeer instance pool,
  362. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  363. CcPlaylistPeer::clearInstancePool();
  364. // Invalidate objects in CcBlockPeer instance pool,
  365. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  366. CcBlockPeer::clearInstancePool();
  367. // Invalidate objects in CcPrefPeer instance pool,
  368. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  369. CcPrefPeer::clearInstancePool();
  370. // Invalidate objects in CcSessPeer instance pool,
  371. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  372. CcSessPeer::clearInstancePool();
  373. // Invalidate objects in CcSubjsTokenPeer instance pool,
  374. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  375. CcSubjsTokenPeer::clearInstancePool();
  376. }
  377. /**
  378. * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
  379. *
  380. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  381. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  382. *
  383. * @param array $row PropelPDO resultset row.
  384. * @param int $startcol The 0-based offset for reading from the resultset row.
  385. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  386. */
  387. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  388. {
  389. // If the PK cannot be derived from the row, return NULL.
  390. if ($row[$startcol] === null) {
  391. return null;
  392. }
  393. return (string) $row[$startcol];
  394. }
  395. /**
  396. * Retrieves the primary key from the DB resultset row
  397. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  398. * a multi-column primary key, an array of the primary key columns will be returned.
  399. *
  400. * @param array $row PropelPDO resultset row.
  401. * @param int $startcol The 0-based offset for reading from the resultset row.
  402. * @return mixed The primary key of the row
  403. */
  404. public static function getPrimaryKeyFromRow($row, $startcol = 0)
  405. {
  406. return (int) $row[$startcol];
  407. }
  408. /**
  409. * The returned array will contain objects of the default type or
  410. * objects that inherit from the default.
  411. *
  412. * @throws PropelException Any exceptions caught during processing will be
  413. * rethrown wrapped into a PropelException.
  414. */
  415. public static function populateObjects(PDOStatement $stmt)
  416. {
  417. $results = array();
  418. // set the class once to avoid overhead in the loop
  419. $cls = CcSubjsPeer::getOMClass(false);
  420. // populate the object(s)
  421. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  422. $key = CcSubjsPeer::getPrimaryKeyHashFromRow($row, 0);
  423. if (null !== ($obj = CcSubjsPeer::getInstanceFromPool($key))) {
  424. // We no longer rehydrate the object, since this can cause data loss.
  425. // See http://www.propelorm.org/ticket/509
  426. // $obj->hydrate($row, 0, true); // rehydrate
  427. $results[] = $obj;
  428. } else {
  429. $obj = new $cls();
  430. $obj->hydrate($row);
  431. $results[] = $obj;
  432. CcSubjsPeer::addInstanceToPool($obj, $key);
  433. } // if key exists
  434. }
  435. $stmt->closeCursor();
  436. return $results;
  437. }
  438. /**
  439. * Populates an object of the default type or an object that inherit from the default.
  440. *
  441. * @param array $row PropelPDO resultset row.
  442. * @param int $startcol The 0-based offset for reading from the resultset row.
  443. * @throws PropelException Any exceptions caught during processing will be
  444. * rethrown wrapped into a PropelException.
  445. * @return array (CcSubjs object, last column rank)
  446. */
  447. public static function populateObject($row, $startcol = 0)
  448. {
  449. $key = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol);
  450. if (null !== ($obj = CcSubjsPeer::getInstanceFromPool($key))) {
  451. // We no longer rehydrate the object, since this can cause data loss.
  452. // See http://www.propelorm.org/ticket/509
  453. // $obj->hydrate($row, $startcol, true); // rehydrate
  454. $col = $startcol + CcSubjsPeer::NUM_COLUMNS;
  455. } else {
  456. $cls = CcSubjsPeer::OM_CLASS;
  457. $obj = new $cls();
  458. $col = $obj->hydrate($row, $startcol);
  459. CcSubjsPeer::addInstanceToPool($obj, $key);
  460. }
  461. return array($obj, $col);
  462. }
  463. /**
  464. * Returns the TableMap related to this peer.
  465. * This method is not needed for general use but a specific application could have a need.
  466. * @return TableMap
  467. * @throws PropelException Any exceptions caught during processing will be
  468. * rethrown wrapped into a PropelException.
  469. */
  470. public static function getTableMap()
  471. {
  472. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  473. }
  474. /**
  475. * Add a TableMap instance to the database for this peer class.
  476. */
  477. public static function buildTableMap()
  478. {
  479. $dbMap = Propel::getDatabaseMap(BaseCcSubjsPeer::DATABASE_NAME);
  480. if (!$dbMap->hasTable(BaseCcSubjsPeer::TABLE_NAME))
  481. {
  482. $dbMap->addTableObject(new CcSubjsTableMap());
  483. }
  484. }
  485. /**
  486. * The class that the Peer will make instances of.
  487. *
  488. * If $withPrefix is true, the returned path
  489. * uses a dot-path notation which is tranalted into a path
  490. * relative to a location on the PHP include_path.
  491. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  492. *
  493. * @param boolean $withPrefix Whether or not to return the path with the class name
  494. * @return string path.to.ClassName
  495. */
  496. public static function getOMClass($withPrefix = true)
  497. {
  498. return $withPrefix ? CcSubjsPeer::CLASS_DEFAULT : CcSubjsPeer::OM_CLASS;
  499. }
  500. /**
  501. * Method perform an INSERT on the database, given a CcSubjs or Criteria object.
  502. *
  503. * @param mixed $values Criteria or CcSubjs object containing data that is used to create the INSERT statement.
  504. * @param PropelPDO $con the PropelPDO connection to use
  505. * @return mixed The new primary key.
  506. * @throws PropelException Any exceptions caught during processing will be
  507. * rethrown wrapped into a PropelException.
  508. */
  509. public static function doInsert($values, PropelPDO $con = null)
  510. {
  511. if ($con === null) {
  512. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  513. }
  514. if ($values instanceof Criteria) {
  515. $criteria = clone $values; // rename for clarity
  516. } else {
  517. $criteria = $values->buildCriteria(); // build Criteria from CcSubjs object
  518. }
  519. if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) {
  520. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
  521. }
  522. // Set the correct dbName
  523. $criteria->setDbName(self::DATABASE_NAME);
  524. try {
  525. // use transaction because $criteria could contain info
  526. // for more than one table (I guess, conceivably)
  527. $con->beginTransaction();
  528. $pk = BasePeer::doInsert($criteria, $con);
  529. $con->commit();
  530. } catch(PropelException $e) {
  531. $con->rollBack();
  532. throw $e;
  533. }
  534. return $pk;
  535. }
  536. /**
  537. * Method perform an UPDATE on the database, given a CcSubjs or Criteria object.
  538. *
  539. * @param mixed $values Criteria or CcSubjs object containing data that is used to create the UPDATE statement.
  540. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  541. * @return int The number of affected rows (if supported by underlying database driver).
  542. * @throws PropelException Any exceptions caught during processing will be
  543. * rethrown wrapped into a PropelException.
  544. */
  545. public static function doUpdate($values, PropelPDO $con = null)
  546. {
  547. if ($con === null) {
  548. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  549. }
  550. $selectCriteria = new Criteria(self::DATABASE_NAME);
  551. if ($values instanceof Criteria) {
  552. $criteria = clone $values; // rename for clarity
  553. $comparison = $criteria->getComparison(CcSubjsPeer::ID);
  554. $value = $criteria->remove(CcSubjsPeer::ID);
  555. if ($value) {
  556. $selectCriteria->add(CcSubjsPeer::ID, $value, $comparison);
  557. } else {
  558. $selectCriteria->setPrimaryTableName(CcSubjsPeer::TABLE_NAME);
  559. }
  560. } else { // $values is CcSubjs object
  561. $criteria = $values->buildCriteria(); // gets full criteria
  562. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  563. }
  564. // set the correct dbName
  565. $criteria->setDbName(self::DATABASE_NAME);
  566. return BasePeer::doUpdate($selectCriteria, $criteria, $con);
  567. }
  568. /**
  569. * Method to DELETE all rows from the cc_subjs table.
  570. *
  571. * @return int The number of affected rows (if supported by underlying database driver).
  572. */
  573. public static function doDeleteAll($con = null)
  574. {
  575. if ($con === null) {
  576. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  577. }
  578. $affectedRows = 0; // initialize var to track total num of affected rows
  579. try {
  580. // use transaction because $criteria could contain info
  581. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  582. $con->beginTransaction();
  583. $affectedRows += BasePeer::doDeleteAll(CcSubjsPeer::TABLE_NAME, $con, CcSubjsPeer::DATABASE_NAME);
  584. // Because this db requires some delete cascade/set null emulation, we have to
  585. // clear the cached instance *after* the emulation has happened (since
  586. // instances get re-added by the select statement contained therein).
  587. CcSubjsPeer::clearInstancePool();
  588. CcSubjsPeer::clearRelatedInstancePool();
  589. $con->commit();
  590. return $affectedRows;
  591. } catch (PropelException $e) {
  592. $con->rollBack();
  593. throw $e;
  594. }
  595. }
  596. /**
  597. * Method perform a DELETE on the database, given a CcSubjs or Criteria object OR a primary key value.
  598. *
  599. * @param mixed $values Criteria or CcSubjs object or primary key or array of primary keys
  600. * which is used to create the DELETE statement
  601. * @param PropelPDO $con the connection to use
  602. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  603. * if supported by native driver or if emulated using Propel.
  604. * @throws PropelException Any exceptions caught during processing will be
  605. * rethrown wrapped into a PropelException.
  606. */
  607. public static function doDelete($values, PropelPDO $con = null)
  608. {
  609. if ($con === null) {
  610. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  611. }
  612. if ($values instanceof Criteria) {
  613. // invalidate the cache for all objects of this type, since we have no
  614. // way of knowing (without running a query) what objects should be invalidated
  615. // from the cache based on this Criteria.
  616. CcSubjsPeer::clearInstancePool();
  617. // rename for clarity
  618. $criteria = clone $values;
  619. } elseif ($values instanceof CcSubjs) { // it's a model object
  620. // invalidate the cache for this single object
  621. CcSubjsPeer::removeInstanceFromPool($values);
  622. // create criteria based on pk values
  623. $criteria = $values->buildPkeyCriteria();
  624. } else { // it's a primary key, or an array of pks
  625. $criteria = new Criteria(self::DATABASE_NAME);
  626. $criteria->add(CcSubjsPeer::ID, (array) $values, Criteria::IN);
  627. // invalidate the cache for this object(s)
  628. foreach ((array) $values as $singleval) {
  629. CcSubjsPeer::removeInstanceFromPool($singleval);
  630. }
  631. }
  632. // Set the correct dbName
  633. $criteria->setDbName(self::DATABASE_NAME);
  634. $affectedRows = 0; // initialize var to track total num of affected rows
  635. try {
  636. // use transaction because $criteria could contain info
  637. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  638. $con->beginTransaction();
  639. $affectedRows += BasePeer::doDelete($criteria, $con);
  640. CcSubjsPeer::clearRelatedInstancePool();
  641. $con->commit();
  642. return $affectedRows;
  643. } catch (PropelException $e) {
  644. $con->rollBack();
  645. throw $e;
  646. }
  647. }
  648. /**
  649. * Validates all modified columns of given CcSubjs object.
  650. * If parameter $columns is either a single column name or an array of column names
  651. * than only those columns are validated.
  652. *
  653. * NOTICE: This does not apply to primary or foreign keys for now.
  654. *
  655. * @param CcSubjs $obj The object to validate.
  656. * @param mixed $cols Column name or array of column names.
  657. *
  658. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  659. */
  660. public static function doValidate(CcSubjs $obj, $cols = null)
  661. {
  662. $columns = array();
  663. if ($cols) {
  664. $dbMap = Propel::getDatabaseMap(CcSubjsPeer::DATABASE_NAME);
  665. $tableMap = $dbMap->getTable(CcSubjsPeer::TABLE_NAME);
  666. if (! is_array($cols)) {
  667. $cols = array($cols);
  668. }
  669. foreach ($cols as $colName) {
  670. if ($tableMap->containsColumn($colName)) {
  671. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  672. $columns[$colName] = $obj->$get();
  673. }
  674. }
  675. } else {
  676. }
  677. return BasePeer::doValidate(CcSubjsPeer::DATABASE_NAME, CcSubjsPeer::TABLE_NAME, $columns);
  678. }
  679. /**
  680. * Retrieve a single object by pkey.
  681. *
  682. * @param int $pk the primary key.
  683. * @param PropelPDO $con the connection to use
  684. * @return CcSubjs
  685. */
  686. public static function retrieveByPK($pk, PropelPDO $con = null)
  687. {
  688. if (null !== ($obj = CcSubjsPeer::getInstanceFromPool((string) $pk))) {
  689. return $obj;
  690. }
  691. if ($con === null) {
  692. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  693. }
  694. $criteria = new Criteria(CcSubjsPeer::DATABASE_NAME);
  695. $criteria->add(CcSubjsPeer::ID, $pk);
  696. $v = CcSubjsPeer::doSelect($criteria, $con);
  697. return !empty($v) > 0 ? $v[0] : null;
  698. }
  699. /**
  700. * Retrieve multiple objects by pkey.
  701. *
  702. * @param array $pks List of primary keys
  703. * @param PropelPDO $con the connection to use
  704. * @throws PropelException Any exceptions caught during processing will be
  705. * rethrown wrapped into a PropelException.
  706. */
  707. public static function retrieveByPKs($pks, PropelPDO $con = null)
  708. {
  709. if ($con === null) {
  710. $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  711. }
  712. $objs = null;
  713. if (empty($pks)) {
  714. $objs = array();
  715. } else {
  716. $criteria = new Criteria(CcSubjsPeer::DATABASE_NAME);
  717. $criteria->add(CcSubjsPeer::ID, $pks, Criteria::IN);
  718. $objs = CcSubjsPeer::doSelect($criteria, $con);
  719. }
  720. return $objs;
  721. }
  722. } // BaseCcSubjsPeer
  723. // This is the static code needed to register the TableMap for this table with the main Propel class.
  724. //
  725. BaseCcSubjsPeer::buildTableMap();