Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Base static class for performing query and update operations on the 'article' table.
5
 *
6
 *
7
 *
8
 * This class was autogenerated by Propel 1.4.2 on:
9
 *
10
 * Fri Aug  5 09:39:34 2011
11
 *
12
 * @package    lib.model.om
13
 */
14
abstract class BaseArticlePeer {
15
 
16
	/** the default database name for this class */
17
	const DATABASE_NAME = 'propel';
18
 
19
	/** the table name for this class */
20
	const TABLE_NAME = 'article';
21
 
22
	/** the related Propel class for this table */
23
	const OM_CLASS = 'Article';
24
 
25
	/** A class that can be returned by this peer. */
26
	const CLASS_DEFAULT = 'lib.model.Article';
27
 
28
	/** the related TableMap class for this table */
29
	const TM_CLASS = 'ArticleTableMap';
30
 
31
	/** The total number of columns. */
32
	const NUM_COLUMNS = 9;
33
 
34
	/** The number of lazy-loaded columns. */
35
	const NUM_LAZY_LOAD_COLUMNS = 0;
36
 
37
	/** the column name for the ID field */
38
	const ID = 'article.ID';
39
 
40
	/** the column name for the TITLE field */
41
	const TITLE = 'article.TITLE';
42
 
43
	/** the column name for the BODY field */
44
	const BODY = 'article.BODY';
45
 
46
	/** the column name for the ONLINE field */
47
	const ONLINE = 'article.ONLINE';
48
 
49
	/** the column name for the EXCERPT field */
50
	const EXCERPT = 'article.EXCERPT';
51
 
52
	/** the column name for the CATEGORY_ID field */
53
	const CATEGORY_ID = 'article.CATEGORY_ID';
54
 
55
	/** the column name for the CREATED_AT field */
56
	const CREATED_AT = 'article.CREATED_AT';
57
 
58
	/** the column name for the END_DATE field */
59
	const END_DATE = 'article.END_DATE';
60
 
61
	/** the column name for the BOOK_ID field */
62
	const BOOK_ID = 'article.BOOK_ID';
63
 
64
	/**
65
	 * An identiy map to hold any loaded instances of Article objects.
66
	 * This must be public so that other peer classes can access this when hydrating from JOIN
67
	 * queries.
68
	 * @var        array Article[]
69
	 */
70
	public static $instances = array();
71
 
72
 
73
	// symfony behavior
74
 
75
	/**
76
	 * Indicates whether the current model includes I18N.
77
	 */
78
	const IS_I18N = false;
79
 
80
	/**
81
	 * holds an array of fieldnames
82
	 *
83
	 * first dimension keys are the type constants
84
	 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
85
	 */
86
	private static $fieldNames = array (
87
		BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Body', 'Online', 'Excerpt', 'CategoryId', 'CreatedAt', 'EndDate', 'BookId', ),
88
		BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'body', 'online', 'excerpt', 'categoryId', 'createdAt', 'endDate', 'bookId', ),
89
		BasePeer::TYPE_COLNAME => array (self::ID, self::TITLE, self::BODY, self::ONLINE, self::EXCERPT, self::CATEGORY_ID, self::CREATED_AT, self::END_DATE, self::BOOK_ID, ),
90
		BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'body', 'Online', 'excerpt', 'category_id', 'created_at', 'end_date', 'book_id', ),
91
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
92
	);
93
 
94
	/**
95
	 * holds an array of keys for quick access to the fieldnames array
96
	 *
97
	 * first dimension keys are the type constants
98
	 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
99
	 */
100
	private static $fieldKeys = array (
101
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Body' => 2, 'Online' => 3, 'Excerpt' => 4, 'CategoryId' => 5, 'CreatedAt' => 6, 'EndDate' => 7, 'BookId' => 8, ),
102
		BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'body' => 2, 'online' => 3, 'excerpt' => 4, 'categoryId' => 5, 'createdAt' => 6, 'endDate' => 7, 'bookId' => 8, ),
103
		BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TITLE => 1, self::BODY => 2, self::ONLINE => 3, self::EXCERPT => 4, self::CATEGORY_ID => 5, self::CREATED_AT => 6, self::END_DATE => 7, self::BOOK_ID => 8, ),
104
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'body' => 2, 'Online' => 3, 'excerpt' => 4, 'category_id' => 5, 'created_at' => 6, 'end_date' => 7, 'book_id' => 8, ),
105
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
106
	);
107
 
108
	/**
109
	 * Translates a fieldname to another type
110
	 *
111
	 * @param      string $name field name
112
	 * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
113
	 *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
114
	 * @param      string $toType   One of the class type constants
115
	 * @return     string translated name of the field.
116
	 * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
117
	 */
118
	static public function translateFieldName($name, $fromType, $toType)
119
	{
120
		$toNames = self::getFieldNames($toType);
121
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
122
		if ($key === null) {
123
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
124
		}
125
		return $toNames[$key];
126
	}
127
 
128
	/**
129
	 * Returns an array of field names.
130
	 *
131
	 * @param      string $type The type of fieldnames to return:
132
	 *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
133
	 *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
134
	 * @return     array A list of field names
135
	 */
136
 
137
	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
138
	{
139
		if (!array_key_exists($type, self::$fieldNames)) {
140
			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.');
141
		}
142
		return self::$fieldNames[$type];
143
	}
144
 
145
	/**
146
	 * Convenience method which changes table.column to alias.column.
147
	 *
148
	 * Using this method you can maintain SQL abstraction while using column aliases.
149
	 * <code>
150
	 *		$c->addAlias("alias1", TablePeer::TABLE_NAME);
151
	 *		$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
152
	 * </code>
153
	 * @param      string $alias The alias for the current table.
154
	 * @param      string $column The column name for current table. (i.e. ArticlePeer::COLUMN_NAME).
155
	 * @return     string
156
	 */
157
	public static function alias($alias, $column)
158
	{
159
		return str_replace(ArticlePeer::TABLE_NAME.'.', $alias.'.', $column);
160
	}
161
 
162
	/**
163
	 * Add all the columns needed to create a new object.
164
	 *
165
	 * Note: any columns that were marked with lazyLoad="true" in the
166
	 * XML schema will not be added to the select list and only loaded
167
	 * on demand.
168
	 *
169
	 * @param      criteria object containing the columns to add.
170
	 * @throws     PropelException Any exceptions caught during processing will be
171
	 *		 rethrown wrapped into a PropelException.
172
	 */
173
	public static function addSelectColumns(Criteria $criteria)
174
	{
175
		$criteria->addSelectColumn(ArticlePeer::ID);
176
		$criteria->addSelectColumn(ArticlePeer::TITLE);
177
		$criteria->addSelectColumn(ArticlePeer::BODY);
178
		$criteria->addSelectColumn(ArticlePeer::ONLINE);
179
		$criteria->addSelectColumn(ArticlePeer::EXCERPT);
180
		$criteria->addSelectColumn(ArticlePeer::CATEGORY_ID);
181
		$criteria->addSelectColumn(ArticlePeer::CREATED_AT);
182
		$criteria->addSelectColumn(ArticlePeer::END_DATE);
183
		$criteria->addSelectColumn(ArticlePeer::BOOK_ID);
184
	}
185
 
186
	/**
187
	 * Returns the number of rows matching criteria.
188
	 *
189
	 * @param      Criteria $criteria
190
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
191
	 * @param      PropelPDO $con
192
	 * @return     int Number of matching rows.
193
	 */
194
	public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
195
	{
196
		// we may modify criteria, so copy it first
197
		$criteria = clone $criteria;
198
 
199
		// We need to set the primary table name, since in the case that there are no WHERE columns
200
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
201
		// tables go into the FROM clause.
202
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
203
 
204
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
205
			$criteria->setDistinct();
206
		}
207
 
208
		if (!$criteria->hasSelectClause()) {
209
			ArticlePeer::addSelectColumns($criteria);
210
		}
211
 
212
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
213
		$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
214
 
215
		if ($con === null) {
216
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
217
		}
218
		// symfony_behaviors behavior
219
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
220
		{
221
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
222
		}
223
 
224
		// BasePeer returns a PDOStatement
225
		$stmt = BasePeer::doCount($criteria, $con);
226
 
227
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
228
			$count = (int) $row[0];
229
		} else {
230
			$count = 0; // no rows returned; we infer that means 0 matches.
231
		}
232
		$stmt->closeCursor();
233
		return $count;
234
	}
235
	/**
236
	 * Method to select one object from the DB.
237
	 *
238
	 * @param      Criteria $criteria object used to create the SELECT statement.
239
	 * @param      PropelPDO $con
240
	 * @return     Article
241
	 * @throws     PropelException Any exceptions caught during processing will be
242
	 *		 rethrown wrapped into a PropelException.
243
	 */
244
	public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
245
	{
246
		$critcopy = clone $criteria;
247
		$critcopy->setLimit(1);
248
		$objects = ArticlePeer::doSelect($critcopy, $con);
249
		if ($objects) {
250
			return $objects[0];
251
		}
252
		return null;
253
	}
254
	/**
255
	 * Method to do selects.
256
	 *
257
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
258
	 * @param      PropelPDO $con
259
	 * @return     array Array of selected Objects
260
	 * @throws     PropelException Any exceptions caught during processing will be
261
	 *		 rethrown wrapped into a PropelException.
262
	 */
263
	public static function doSelect(Criteria $criteria, PropelPDO $con = null)
264
	{
265
		return ArticlePeer::populateObjects(ArticlePeer::doSelectStmt($criteria, $con));
266
	}
267
	/**
268
	 * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
269
	 *
270
	 * Use this method directly if you want to work with an executed statement durirectly (for example
271
	 * to perform your own object hydration).
272
	 *
273
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
274
	 * @param      PropelPDO $con The connection to use
275
	 * @throws     PropelException Any exceptions caught during processing will be
276
	 *		 rethrown wrapped into a PropelException.
277
	 * @return     PDOStatement The executed PDOStatement object.
278
	 * @see        BasePeer::doSelect()
279
	 */
280
	public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
281
	{
282
		if ($con === null) {
283
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
284
		}
285
 
286
		if (!$criteria->hasSelectClause()) {
287
			$criteria = clone $criteria;
288
			ArticlePeer::addSelectColumns($criteria);
289
		}
290
 
291
		// Set the correct dbName
292
		$criteria->setDbName(self::DATABASE_NAME);
293
		// symfony_behaviors behavior
294
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
295
		{
296
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
297
		}
298
 
299
 
300
		// BasePeer returns a PDOStatement
301
		return BasePeer::doSelect($criteria, $con);
302
	}
303
	/**
304
	 * Adds an object to the instance pool.
305
	 *
306
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
307
	 * from the database.  In some cases -- especially when you override doSelect*()
308
	 * methods in your stub classes -- you may need to explicitly add objects
309
	 * to the cache in order to ensure that the same objects are always returned by doSelect*()
310
	 * and retrieveByPK*() calls.
311
	 *
312
	 * @param      Article $value A Article object.
313
	 * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
314
	 */
315
	public static function addInstanceToPool(Article $obj, $key = null)
316
	{
317
		if (Propel::isInstancePoolingEnabled()) {
318
			if ($key === null) {
319
				$key = (string) $obj->getId();
320
			} // if key === null
321
			self::$instances[$key] = $obj;
322
		}
323
	}
324
 
325
	/**
326
	 * Removes an object from the instance pool.
327
	 *
328
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
329
	 * from the database.  In some cases -- especially when you override doDelete
330
	 * methods in your stub classes -- you may need to explicitly remove objects
331
	 * from the cache in order to prevent returning objects that no longer exist.
332
	 *
333
	 * @param      mixed $value A Article object or a primary key value.
334
	 */
335
	public static function removeInstanceFromPool($value)
336
	{
337
		if (Propel::isInstancePoolingEnabled() && $value !== null) {
338
			if (is_object($value) && $value instanceof Article) {
339
				$key = (string) $value->getId();
340
			} elseif (is_scalar($value)) {
341
				// assume we've been passed a primary key
342
				$key = (string) $value;
343
			} else {
344
				$e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Article object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
345
				throw $e;
346
			}
347
 
348
			unset(self::$instances[$key]);
349
		}
350
	} // removeInstanceFromPool()
351
 
352
	/**
353
	 * 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.
354
	 *
355
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
356
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
357
	 *
358
	 * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
359
	 * @return     Article Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
360
	 * @see        getPrimaryKeyHash()
361
	 */
362
	public static function getInstanceFromPool($key)
363
	{
364
		if (Propel::isInstancePoolingEnabled()) {
365
			if (isset(self::$instances[$key])) {
366
				return self::$instances[$key];
367
			}
368
		}
369
		return null; // just to be explicit
370
	}
371
 
372
	/**
373
	 * Clear the instance pool.
374
	 *
375
	 * @return     void
376
	 */
377
	public static function clearInstancePool()
378
	{
379
		self::$instances = array();
380
	}
381
 
382
	/**
383
	 * Method to invalidate the instance pool of all tables related to article
384
	 * by a foreign key with ON DELETE CASCADE
385
	 */
386
	public static function clearRelatedInstancePool()
387
	{
388
	}
389
 
390
	/**
391
	 * 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.
392
	 *
393
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
394
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
395
	 *
396
	 * @param      array $row PropelPDO resultset row.
397
	 * @param      int $startcol The 0-based offset for reading from the resultset row.
398
	 * @return     string A string version of PK or NULL if the components of primary key in result array are all null.
399
	 */
400
	public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
401
	{
402
		// If the PK cannot be derived from the row, return NULL.
403
		if ($row[$startcol] === null) {
404
			return null;
405
		}
406
		return (string) $row[$startcol];
407
	}
408
 
409
	/**
410
	 * The returned array will contain objects of the default type or
411
	 * objects that inherit from the default.
412
	 *
413
	 * @throws     PropelException Any exceptions caught during processing will be
414
	 *		 rethrown wrapped into a PropelException.
415
	 */
416
	public static function populateObjects(PDOStatement $stmt)
417
	{
418
		$results = array();
419
 
420
		// set the class once to avoid overhead in the loop
421
		$cls = ArticlePeer::getOMClass(false);
422
		// populate the object(s)
423
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
424
			$key = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
425
			if (null !== ($obj = ArticlePeer::getInstanceFromPool($key))) {
426
				// We no longer rehydrate the object, since this can cause data loss.
427
				// See http://propel.phpdb.org/trac/ticket/509
428
				// $obj->hydrate($row, 0, true); // rehydrate
429
				$results[] = $obj;
430
			} else {
431
				$obj = new $cls();
432
				$obj->hydrate($row);
433
				$results[] = $obj;
434
				ArticlePeer::addInstanceToPool($obj, $key);
435
			} // if key exists
436
		}
437
		$stmt->closeCursor();
438
		return $results;
439
	}
440
 
441
	/**
442
	 * Returns the number of rows matching criteria, joining the related Category table
443
	 *
444
	 * @param      Criteria $criteria
445
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
446
	 * @param      PropelPDO $con
447
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
448
	 * @return     int Number of matching rows.
449
	 */
450
	public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
451
	{
452
		// we're going to modify criteria, so copy it first
453
		$criteria = clone $criteria;
454
 
455
		// We need to set the primary table name, since in the case that there are no WHERE columns
456
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
457
		// tables go into the FROM clause.
458
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
459
 
460
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
461
			$criteria->setDistinct();
462
		}
463
 
464
		if (!$criteria->hasSelectClause()) {
465
			ArticlePeer::addSelectColumns($criteria);
466
		}
467
 
468
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
469
 
470
		// Set the correct dbName
471
		$criteria->setDbName(self::DATABASE_NAME);
472
 
473
		if ($con === null) {
474
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
475
		}
476
 
477
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
478
 
479
		// symfony_behaviors behavior
480
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
481
		{
482
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
483
		}
484
 
485
		$stmt = BasePeer::doCount($criteria, $con);
486
 
487
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
488
			$count = (int) $row[0];
489
		} else {
490
			$count = 0; // no rows returned; we infer that means 0 matches.
491
		}
492
		$stmt->closeCursor();
493
		return $count;
494
	}
495
 
496
 
497
	/**
498
	 * Returns the number of rows matching criteria, joining the related Book table
499
	 *
500
	 * @param      Criteria $criteria
501
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
502
	 * @param      PropelPDO $con
503
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
504
	 * @return     int Number of matching rows.
505
	 */
506
	public static function doCountJoinBook(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
507
	{
508
		// we're going to modify criteria, so copy it first
509
		$criteria = clone $criteria;
510
 
511
		// We need to set the primary table name, since in the case that there are no WHERE columns
512
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
513
		// tables go into the FROM clause.
514
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
515
 
516
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
517
			$criteria->setDistinct();
518
		}
519
 
520
		if (!$criteria->hasSelectClause()) {
521
			ArticlePeer::addSelectColumns($criteria);
522
		}
523
 
524
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
525
 
526
		// Set the correct dbName
527
		$criteria->setDbName(self::DATABASE_NAME);
528
 
529
		if ($con === null) {
530
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
531
		}
532
 
533
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
534
 
535
		// symfony_behaviors behavior
536
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
537
		{
538
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
539
		}
540
 
541
		$stmt = BasePeer::doCount($criteria, $con);
542
 
543
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
544
			$count = (int) $row[0];
545
		} else {
546
			$count = 0; // no rows returned; we infer that means 0 matches.
547
		}
548
		$stmt->closeCursor();
549
		return $count;
550
	}
551
 
552
 
553
	/**
554
	 * Selects a collection of Article objects pre-filled with their Category objects.
555
	 * @param      Criteria  $criteria
556
	 * @param      PropelPDO $con
557
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
558
	 * @return     array Array of Article objects.
559
	 * @throws     PropelException Any exceptions caught during processing will be
560
	 *		 rethrown wrapped into a PropelException.
561
	 */
562
	public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
563
	{
564
		$criteria = clone $criteria;
565
 
566
		// Set the correct dbName if it has not been overridden
567
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
568
			$criteria->setDbName(self::DATABASE_NAME);
569
		}
570
 
571
		ArticlePeer::addSelectColumns($criteria);
572
		$startcol = (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
573
		CategoryPeer::addSelectColumns($criteria);
574
 
575
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
576
 
577
		// symfony_behaviors behavior
578
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
579
		{
580
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
581
		}
582
 
583
		$stmt = BasePeer::doSelect($criteria, $con);
584
		$results = array();
585
 
586
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
587
			$key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
588
			if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
589
				// We no longer rehydrate the object, since this can cause data loss.
590
				// See http://propel.phpdb.org/trac/ticket/509
591
				// $obj1->hydrate($row, 0, true); // rehydrate
592
			} else {
593
 
594
				$cls = ArticlePeer::getOMClass(false);
595
 
596
				$obj1 = new $cls();
597
				$obj1->hydrate($row);
598
				ArticlePeer::addInstanceToPool($obj1, $key1);
599
			} // if $obj1 already loaded
600
 
601
			$key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
602
			if ($key2 !== null) {
603
				$obj2 = CategoryPeer::getInstanceFromPool($key2);
604
				if (!$obj2) {
605
 
606
					$cls = CategoryPeer::getOMClass(false);
607
 
608
					$obj2 = new $cls();
609
					$obj2->hydrate($row, $startcol);
610
					CategoryPeer::addInstanceToPool($obj2, $key2);
611
				} // if obj2 already loaded
612
 
613
				// Add the $obj1 (Article) to $obj2 (Category)
614
				$obj2->addArticle($obj1);
615
 
616
			} // if joined row was not null
617
 
618
			$results[] = $obj1;
619
		}
620
		$stmt->closeCursor();
621
		return $results;
622
	}
623
 
624
 
625
	/**
626
	 * Selects a collection of Article objects pre-filled with their Book objects.
627
	 * @param      Criteria  $criteria
628
	 * @param      PropelPDO $con
629
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
630
	 * @return     array Array of Article objects.
631
	 * @throws     PropelException Any exceptions caught during processing will be
632
	 *		 rethrown wrapped into a PropelException.
633
	 */
634
	public static function doSelectJoinBook(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
635
	{
636
		$criteria = clone $criteria;
637
 
638
		// Set the correct dbName if it has not been overridden
639
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
640
			$criteria->setDbName(self::DATABASE_NAME);
641
		}
642
 
643
		ArticlePeer::addSelectColumns($criteria);
644
		$startcol = (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
645
		BookPeer::addSelectColumns($criteria);
646
 
647
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
648
 
649
		// symfony_behaviors behavior
650
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
651
		{
652
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
653
		}
654
 
655
		$stmt = BasePeer::doSelect($criteria, $con);
656
		$results = array();
657
 
658
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
659
			$key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
660
			if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
661
				// We no longer rehydrate the object, since this can cause data loss.
662
				// See http://propel.phpdb.org/trac/ticket/509
663
				// $obj1->hydrate($row, 0, true); // rehydrate
664
			} else {
665
 
666
				$cls = ArticlePeer::getOMClass(false);
667
 
668
				$obj1 = new $cls();
669
				$obj1->hydrate($row);
670
				ArticlePeer::addInstanceToPool($obj1, $key1);
671
			} // if $obj1 already loaded
672
 
673
			$key2 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol);
674
			if ($key2 !== null) {
675
				$obj2 = BookPeer::getInstanceFromPool($key2);
676
				if (!$obj2) {
677
 
678
					$cls = BookPeer::getOMClass(false);
679
 
680
					$obj2 = new $cls();
681
					$obj2->hydrate($row, $startcol);
682
					BookPeer::addInstanceToPool($obj2, $key2);
683
				} // if obj2 already loaded
684
 
685
				// Add the $obj1 (Article) to $obj2 (Book)
686
				$obj2->addArticle($obj1);
687
 
688
			} // if joined row was not null
689
 
690
			$results[] = $obj1;
691
		}
692
		$stmt->closeCursor();
693
		return $results;
694
	}
695
 
696
 
697
	/**
698
	 * Returns the number of rows matching criteria, joining all related tables
699
	 *
700
	 * @param      Criteria $criteria
701
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
702
	 * @param      PropelPDO $con
703
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
704
	 * @return     int Number of matching rows.
705
	 */
706
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
707
	{
708
		// we're going to modify criteria, so copy it first
709
		$criteria = clone $criteria;
710
 
711
		// We need to set the primary table name, since in the case that there are no WHERE columns
712
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
713
		// tables go into the FROM clause.
714
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
715
 
716
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
717
			$criteria->setDistinct();
718
		}
719
 
720
		if (!$criteria->hasSelectClause()) {
721
			ArticlePeer::addSelectColumns($criteria);
722
		}
723
 
724
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
725
 
726
		// Set the correct dbName
727
		$criteria->setDbName(self::DATABASE_NAME);
728
 
729
		if ($con === null) {
730
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
731
		}
732
 
733
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
734
 
735
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
736
 
737
		// symfony_behaviors behavior
738
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
739
		{
740
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
741
		}
742
 
743
		$stmt = BasePeer::doCount($criteria, $con);
744
 
745
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
746
			$count = (int) $row[0];
747
		} else {
748
			$count = 0; // no rows returned; we infer that means 0 matches.
749
		}
750
		$stmt->closeCursor();
751
		return $count;
752
	}
753
 
754
	/**
755
	 * Selects a collection of Article objects pre-filled with all related objects.
756
	 *
757
	 * @param      Criteria  $criteria
758
	 * @param      PropelPDO $con
759
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
760
	 * @return     array Array of Article objects.
761
	 * @throws     PropelException Any exceptions caught during processing will be
762
	 *		 rethrown wrapped into a PropelException.
763
	 */
764
	public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
765
	{
766
		$criteria = clone $criteria;
767
 
768
		// Set the correct dbName if it has not been overridden
769
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
770
			$criteria->setDbName(self::DATABASE_NAME);
771
		}
772
 
773
		ArticlePeer::addSelectColumns($criteria);
774
		$startcol2 = (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
775
 
776
		CategoryPeer::addSelectColumns($criteria);
777
		$startcol3 = $startcol2 + (CategoryPeer::NUM_COLUMNS - CategoryPeer::NUM_LAZY_LOAD_COLUMNS);
778
 
779
		BookPeer::addSelectColumns($criteria);
780
		$startcol4 = $startcol3 + (BookPeer::NUM_COLUMNS - BookPeer::NUM_LAZY_LOAD_COLUMNS);
781
 
782
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
783
 
784
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
785
 
786
		// symfony_behaviors behavior
787
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
788
		{
789
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
790
		}
791
 
792
		$stmt = BasePeer::doSelect($criteria, $con);
793
		$results = array();
794
 
795
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
796
			$key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
797
			if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
798
				// We no longer rehydrate the object, since this can cause data loss.
799
				// See http://propel.phpdb.org/trac/ticket/509
800
				// $obj1->hydrate($row, 0, true); // rehydrate
801
			} else {
802
				$cls = ArticlePeer::getOMClass(false);
803
 
804
				$obj1 = new $cls();
805
				$obj1->hydrate($row);
806
				ArticlePeer::addInstanceToPool($obj1, $key1);
807
			} // if obj1 already loaded
808
 
809
			// Add objects for joined Category rows
810
 
811
			$key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
812
			if ($key2 !== null) {
813
				$obj2 = CategoryPeer::getInstanceFromPool($key2);
814
				if (!$obj2) {
815
 
816
					$cls = CategoryPeer::getOMClass(false);
817
 
818
					$obj2 = new $cls();
819
					$obj2->hydrate($row, $startcol2);
820
					CategoryPeer::addInstanceToPool($obj2, $key2);
821
				} // if obj2 loaded
822
 
823
				// Add the $obj1 (Article) to the collection in $obj2 (Category)
824
				$obj2->addArticle($obj1);
825
			} // if joined row not null
826
 
827
			// Add objects for joined Book rows
828
 
829
			$key3 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol3);
830
			if ($key3 !== null) {
831
				$obj3 = BookPeer::getInstanceFromPool($key3);
832
				if (!$obj3) {
833
 
834
					$cls = BookPeer::getOMClass(false);
835
 
836
					$obj3 = new $cls();
837
					$obj3->hydrate($row, $startcol3);
838
					BookPeer::addInstanceToPool($obj3, $key3);
839
				} // if obj3 loaded
840
 
841
				// Add the $obj1 (Article) to the collection in $obj3 (Book)
842
				$obj3->addArticle($obj1);
843
			} // if joined row not null
844
 
845
			$results[] = $obj1;
846
		}
847
		$stmt->closeCursor();
848
		return $results;
849
	}
850
 
851
 
852
	/**
853
	 * Returns the number of rows matching criteria, joining the related Category table
854
	 *
855
	 * @param      Criteria $criteria
856
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
857
	 * @param      PropelPDO $con
858
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
859
	 * @return     int Number of matching rows.
860
	 */
861
	public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
862
	{
863
		// we're going to modify criteria, so copy it first
864
		$criteria = clone $criteria;
865
 
866
		// We need to set the primary table name, since in the case that there are no WHERE columns
867
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
868
		// tables go into the FROM clause.
869
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
870
 
871
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
872
			$criteria->setDistinct();
873
		}
874
 
875
		if (!$criteria->hasSelectClause()) {
876
			ArticlePeer::addSelectColumns($criteria);
877
		}
878
 
879
		$criteria->clearOrderByColumns(); // ORDER BY should not affect count
880
 
881
		// Set the correct dbName
882
		$criteria->setDbName(self::DATABASE_NAME);
883
 
884
		if ($con === null) {
885
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
886
		}
887
 
888
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
889
 
890
		// symfony_behaviors behavior
891
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
892
		{
893
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
894
		}
895
 
896
		$stmt = BasePeer::doCount($criteria, $con);
897
 
898
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
899
			$count = (int) $row[0];
900
		} else {
901
			$count = 0; // no rows returned; we infer that means 0 matches.
902
		}
903
		$stmt->closeCursor();
904
		return $count;
905
	}
906
 
907
 
908
	/**
909
	 * Returns the number of rows matching criteria, joining the related Book table
910
	 *
911
	 * @param      Criteria $criteria
912
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
913
	 * @param      PropelPDO $con
914
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
915
	 * @return     int Number of matching rows.
916
	 */
917
	public static function doCountJoinAllExceptBook(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
918
	{
919
		// we're going to modify criteria, so copy it first
920
		$criteria = clone $criteria;
921
 
922
		// We need to set the primary table name, since in the case that there are no WHERE columns
923
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
924
		// tables go into the FROM clause.
925
		$criteria->setPrimaryTableName(ArticlePeer::TABLE_NAME);
926
 
927
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
928
			$criteria->setDistinct();
929
		}
930
 
931
		if (!$criteria->hasSelectClause()) {
932
			ArticlePeer::addSelectColumns($criteria);
933
		}
934
 
935
		$criteria->clearOrderByColumns(); // ORDER BY should not affect count
936
 
937
		// Set the correct dbName
938
		$criteria->setDbName(self::DATABASE_NAME);
939
 
940
		if ($con === null) {
941
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
942
		}
943
 
944
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
945
 
946
		// symfony_behaviors behavior
947
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
948
		{
949
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
950
		}
951
 
952
		$stmt = BasePeer::doCount($criteria, $con);
953
 
954
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
955
			$count = (int) $row[0];
956
		} else {
957
			$count = 0; // no rows returned; we infer that means 0 matches.
958
		}
959
		$stmt->closeCursor();
960
		return $count;
961
	}
962
 
963
 
964
	/**
965
	 * Selects a collection of Article objects pre-filled with all related objects except Category.
966
	 *
967
	 * @param      Criteria  $criteria
968
	 * @param      PropelPDO $con
969
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
970
	 * @return     array Array of Article objects.
971
	 * @throws     PropelException Any exceptions caught during processing will be
972
	 *		 rethrown wrapped into a PropelException.
973
	 */
974
	public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
975
	{
976
		$criteria = clone $criteria;
977
 
978
		// Set the correct dbName if it has not been overridden
979
		// $criteria->getDbName() will return the same object if not set to another value
980
		// so == check is okay and faster
981
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
982
			$criteria->setDbName(self::DATABASE_NAME);
983
		}
984
 
985
		ArticlePeer::addSelectColumns($criteria);
986
		$startcol2 = (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
987
 
988
		BookPeer::addSelectColumns($criteria);
989
		$startcol3 = $startcol2 + (BookPeer::NUM_COLUMNS - BookPeer::NUM_LAZY_LOAD_COLUMNS);
990
 
991
		$criteria->addJoin(ArticlePeer::BOOK_ID, BookPeer::ID, $join_behavior);
992
 
993
		// symfony_behaviors behavior
994
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
995
		{
996
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
997
		}
998
 
999
 
1000
		$stmt = BasePeer::doSelect($criteria, $con);
1001
		$results = array();
1002
 
1003
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1004
			$key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
1005
			if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
1006
				// We no longer rehydrate the object, since this can cause data loss.
1007
				// See http://propel.phpdb.org/trac/ticket/509
1008
				// $obj1->hydrate($row, 0, true); // rehydrate
1009
			} else {
1010
				$cls = ArticlePeer::getOMClass(false);
1011
 
1012
				$obj1 = new $cls();
1013
				$obj1->hydrate($row);
1014
				ArticlePeer::addInstanceToPool($obj1, $key1);
1015
			} // if obj1 already loaded
1016
 
1017
				// Add objects for joined Book rows
1018
 
1019
				$key2 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol2);
1020
				if ($key2 !== null) {
1021
					$obj2 = BookPeer::getInstanceFromPool($key2);
1022
					if (!$obj2) {
1023
 
1024
						$cls = BookPeer::getOMClass(false);
1025
 
1026
					$obj2 = new $cls();
1027
					$obj2->hydrate($row, $startcol2);
1028
					BookPeer::addInstanceToPool($obj2, $key2);
1029
				} // if $obj2 already loaded
1030
 
1031
				// Add the $obj1 (Article) to the collection in $obj2 (Book)
1032
				$obj2->addArticle($obj1);
1033
 
1034
			} // if joined row is not null
1035
 
1036
			$results[] = $obj1;
1037
		}
1038
		$stmt->closeCursor();
1039
		return $results;
1040
	}
1041
 
1042
 
1043
	/**
1044
	 * Selects a collection of Article objects pre-filled with all related objects except Book.
1045
	 *
1046
	 * @param      Criteria  $criteria
1047
	 * @param      PropelPDO $con
1048
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
1049
	 * @return     array Array of Article objects.
1050
	 * @throws     PropelException Any exceptions caught during processing will be
1051
	 *		 rethrown wrapped into a PropelException.
1052
	 */
1053
	public static function doSelectJoinAllExceptBook(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1054
	{
1055
		$criteria = clone $criteria;
1056
 
1057
		// Set the correct dbName if it has not been overridden
1058
		// $criteria->getDbName() will return the same object if not set to another value
1059
		// so == check is okay and faster
1060
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
1061
			$criteria->setDbName(self::DATABASE_NAME);
1062
		}
1063
 
1064
		ArticlePeer::addSelectColumns($criteria);
1065
		$startcol2 = (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
1066
 
1067
		CategoryPeer::addSelectColumns($criteria);
1068
		$startcol3 = $startcol2 + (CategoryPeer::NUM_COLUMNS - CategoryPeer::NUM_LAZY_LOAD_COLUMNS);
1069
 
1070
		$criteria->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
1071
 
1072
		// symfony_behaviors behavior
1073
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
1074
		{
1075
		  call_user_func($sf_hook, 'BaseArticlePeer', $criteria, $con);
1076
		}
1077
 
1078
 
1079
		$stmt = BasePeer::doSelect($criteria, $con);
1080
		$results = array();
1081
 
1082
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1083
			$key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
1084
			if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
1085
				// We no longer rehydrate the object, since this can cause data loss.
1086
				// See http://propel.phpdb.org/trac/ticket/509
1087
				// $obj1->hydrate($row, 0, true); // rehydrate
1088
			} else {
1089
				$cls = ArticlePeer::getOMClass(false);
1090
 
1091
				$obj1 = new $cls();
1092
				$obj1->hydrate($row);
1093
				ArticlePeer::addInstanceToPool($obj1, $key1);
1094
			} // if obj1 already loaded
1095
 
1096
				// Add objects for joined Category rows
1097
 
1098
				$key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
1099
				if ($key2 !== null) {
1100
					$obj2 = CategoryPeer::getInstanceFromPool($key2);
1101
					if (!$obj2) {
1102
 
1103
						$cls = CategoryPeer::getOMClass(false);
1104
 
1105
					$obj2 = new $cls();
1106
					$obj2->hydrate($row, $startcol2);
1107
					CategoryPeer::addInstanceToPool($obj2, $key2);
1108
				} // if $obj2 already loaded
1109
 
1110
				// Add the $obj1 (Article) to the collection in $obj2 (Category)
1111
				$obj2->addArticle($obj1);
1112
 
1113
			} // if joined row is not null
1114
 
1115
			$results[] = $obj1;
1116
		}
1117
		$stmt->closeCursor();
1118
		return $results;
1119
	}
1120
 
1121
	/**
1122
	 * Returns the TableMap related to this peer.
1123
	 * This method is not needed for general use but a specific application could have a need.
1124
	 * @return     TableMap
1125
	 * @throws     PropelException Any exceptions caught during processing will be
1126
	 *		 rethrown wrapped into a PropelException.
1127
	 */
1128
	public static function getTableMap()
1129
	{
1130
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
1131
	}
1132
 
1133
	/**
1134
	 * Add a TableMap instance to the database for this peer class.
1135
	 */
1136
	public static function buildTableMap()
1137
	{
1138
	  $dbMap = Propel::getDatabaseMap(BaseArticlePeer::DATABASE_NAME);
1139
	  if (!$dbMap->hasTable(BaseArticlePeer::TABLE_NAME))
1140
	  {
1141
	    $dbMap->addTableObject(new ArticleTableMap());
1142
	  }
1143
	}
1144
 
1145
	/**
1146
	 * The class that the Peer will make instances of.
1147
	 *
1148
	 * If $withPrefix is true, the returned path
1149
	 * uses a dot-path notation which is tranalted into a path
1150
	 * relative to a location on the PHP include_path.
1151
	 * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
1152
	 *
1153
	 * @param      boolean  Whether or not to return the path wit hthe class name
1154
	 * @return     string path.to.ClassName
1155
	 */
1156
	public static function getOMClass($withPrefix = true)
1157
	{
1158
		return $withPrefix ? ArticlePeer::CLASS_DEFAULT : ArticlePeer::OM_CLASS;
1159
	}
1160
 
1161
	/**
1162
	 * Method perform an INSERT on the database, given a Article or Criteria object.
1163
	 *
1164
	 * @param      mixed $values Criteria or Article object containing data that is used to create the INSERT statement.
1165
	 * @param      PropelPDO $con the PropelPDO connection to use
1166
	 * @return     mixed The new primary key.
1167
	 * @throws     PropelException Any exceptions caught during processing will be
1168
	 *		 rethrown wrapped into a PropelException.
1169
	 */
1170
	public static function doInsert($values, PropelPDO $con = null)
1171
	{
1172
    // symfony_behaviors behavior
1173
    foreach (sfMixer::getCallables('BaseArticlePeer:doInsert:pre') as $sf_hook)
1174
    {
1175
      if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseArticlePeer', $values, $con))
1176
      {
1177
        return $sf_hook_retval;
1178
      }
1179
    }
1180
 
1181
		if ($con === null) {
1182
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1183
		}
1184
 
1185
		if ($values instanceof Criteria) {
1186
			$criteria = clone $values; // rename for clarity
1187
		} else {
1188
			$criteria = $values->buildCriteria(); // build Criteria from Article object
1189
		}
1190
 
1191
		if ($criteria->containsKey(ArticlePeer::ID) && $criteria->keyContainsValue(ArticlePeer::ID) ) {
1192
			throw new PropelException('Cannot insert a value for auto-increment primary key ('.ArticlePeer::ID.')');
1193
		}
1194
 
1195
 
1196
		// Set the correct dbName
1197
		$criteria->setDbName(self::DATABASE_NAME);
1198
 
1199
		try {
1200
			// use transaction because $criteria could contain info
1201
			// for more than one table (I guess, conceivably)
1202
			$con->beginTransaction();
1203
			$pk = BasePeer::doInsert($criteria, $con);
1204
			$con->commit();
1205
		} catch(PropelException $e) {
1206
			$con->rollBack();
1207
			throw $e;
1208
		}
1209
 
1210
    // symfony_behaviors behavior
1211
    foreach (sfMixer::getCallables('BaseArticlePeer:doInsert:post') as $sf_hook)
1212
    {
1213
      call_user_func($sf_hook, 'BaseArticlePeer', $values, $con, $pk);
1214
    }
1215
 
1216
		return $pk;
1217
	}
1218
 
1219
	/**
1220
	 * Method perform an UPDATE on the database, given a Article or Criteria object.
1221
	 *
1222
	 * @param      mixed $values Criteria or Article object containing data that is used to create the UPDATE statement.
1223
	 * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
1224
	 * @return     int The number of affected rows (if supported by underlying database driver).
1225
	 * @throws     PropelException Any exceptions caught during processing will be
1226
	 *		 rethrown wrapped into a PropelException.
1227
	 */
1228
	public static function doUpdate($values, PropelPDO $con = null)
1229
	{
1230
    // symfony_behaviors behavior
1231
    foreach (sfMixer::getCallables('BaseArticlePeer:doUpdate:pre') as $sf_hook)
1232
    {
1233
      if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseArticlePeer', $values, $con))
1234
      {
1235
        return $sf_hook_retval;
1236
      }
1237
    }
1238
 
1239
		if ($con === null) {
1240
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1241
		}
1242
 
1243
		$selectCriteria = new Criteria(self::DATABASE_NAME);
1244
 
1245
		if ($values instanceof Criteria) {
1246
			$criteria = clone $values; // rename for clarity
1247
 
1248
			$comparison = $criteria->getComparison(ArticlePeer::ID);
1249
			$selectCriteria->add(ArticlePeer::ID, $criteria->remove(ArticlePeer::ID), $comparison);
1250
 
1251
		} else { // $values is Article object
1252
			$criteria = $values->buildCriteria(); // gets full criteria
1253
			$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
1254
		}
1255
 
1256
		// set the correct dbName
1257
		$criteria->setDbName(self::DATABASE_NAME);
1258
 
1259
		$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
1260
 
1261
    // symfony_behaviors behavior
1262
    foreach (sfMixer::getCallables('BaseArticlePeer:doUpdate:post') as $sf_hook)
1263
    {
1264
      call_user_func($sf_hook, 'BaseArticlePeer', $values, $con, $ret);
1265
    }
1266
 
1267
    return $ret;
1268
	}
1269
 
1270
	/**
1271
	 * Method to DELETE all rows from the article table.
1272
	 *
1273
	 * @return     int The number of affected rows (if supported by underlying database driver).
1274
	 */
1275
	public static function doDeleteAll($con = null)
1276
	{
1277
		if ($con === null) {
1278
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1279
		}
1280
		$affectedRows = 0; // initialize var to track total num of affected rows
1281
		try {
1282
			// use transaction because $criteria could contain info
1283
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
1284
			$con->beginTransaction();
1285
			$affectedRows += BasePeer::doDeleteAll(ArticlePeer::TABLE_NAME, $con);
1286
			// Because this db requires some delete cascade/set null emulation, we have to
1287
			// clear the cached instance *after* the emulation has happened (since
1288
			// instances get re-added by the select statement contained therein).
1289
			ArticlePeer::clearInstancePool();
1290
			ArticlePeer::clearRelatedInstancePool();
1291
			$con->commit();
1292
			return $affectedRows;
1293
		} catch (PropelException $e) {
1294
			$con->rollBack();
1295
			throw $e;
1296
		}
1297
	}
1298
 
1299
	/**
1300
	 * Method perform a DELETE on the database, given a Article or Criteria object OR a primary key value.
1301
	 *
1302
	 * @param      mixed $values Criteria or Article object or primary key or array of primary keys
1303
	 *              which is used to create the DELETE statement
1304
	 * @param      PropelPDO $con the connection to use
1305
	 * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
1306
	 *				if supported by native driver or if emulated using Propel.
1307
	 * @throws     PropelException Any exceptions caught during processing will be
1308
	 *		 rethrown wrapped into a PropelException.
1309
	 */
1310
	 public static function doDelete($values, PropelPDO $con = null)
1311
	 {
1312
		if ($con === null) {
1313
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1314
		}
1315
 
1316
		if ($values instanceof Criteria) {
1317
			// invalidate the cache for all objects of this type, since we have no
1318
			// way of knowing (without running a query) what objects should be invalidated
1319
			// from the cache based on this Criteria.
1320
			ArticlePeer::clearInstancePool();
1321
			// rename for clarity
1322
			$criteria = clone $values;
1323
		} elseif ($values instanceof Article) { // it's a model object
1324
			// invalidate the cache for this single object
1325
			ArticlePeer::removeInstanceFromPool($values);
1326
			// create criteria based on pk values
1327
			$criteria = $values->buildPkeyCriteria();
1328
		} else { // it's a primary key, or an array of pks
1329
			$criteria = new Criteria(self::DATABASE_NAME);
1330
			$criteria->add(ArticlePeer::ID, (array) $values, Criteria::IN);
1331
			// invalidate the cache for this object(s)
1332
			foreach ((array) $values as $singleval) {
1333
				ArticlePeer::removeInstanceFromPool($singleval);
1334
			}
1335
		}
1336
 
1337
		// Set the correct dbName
1338
		$criteria->setDbName(self::DATABASE_NAME);
1339
 
1340
		$affectedRows = 0; // initialize var to track total num of affected rows
1341
 
1342
		try {
1343
			// use transaction because $criteria could contain info
1344
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
1345
			$con->beginTransaction();
1346
 
1347
			$affectedRows += BasePeer::doDelete($criteria, $con);
1348
			ArticlePeer::clearRelatedInstancePool();
1349
			$con->commit();
1350
			return $affectedRows;
1351
		} catch (PropelException $e) {
1352
			$con->rollBack();
1353
			throw $e;
1354
		}
1355
	}
1356
 
1357
	/**
1358
	 * Validates all modified columns of given Article object.
1359
	 * If parameter $columns is either a single column name or an array of column names
1360
	 * than only those columns are validated.
1361
	 *
1362
	 * NOTICE: This does not apply to primary or foreign keys for now.
1363
	 *
1364
	 * @param      Article $obj The object to validate.
1365
	 * @param      mixed $cols Column name or array of column names.
1366
	 *
1367
	 * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
1368
	 */
1369
	public static function doValidate(Article $obj, $cols = null)
1370
	{
1371
		$columns = array();
1372
 
1373
		if ($cols) {
1374
			$dbMap = Propel::getDatabaseMap(ArticlePeer::DATABASE_NAME);
1375
			$tableMap = $dbMap->getTable(ArticlePeer::TABLE_NAME);
1376
 
1377
			if (! is_array($cols)) {
1378
				$cols = array($cols);
1379
			}
1380
 
1381
			foreach ($cols as $colName) {
1382
				if ($tableMap->containsColumn($colName)) {
1383
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
1384
					$columns[$colName] = $obj->$get();
1385
				}
1386
			}
1387
		} else {
1388
 
1389
		}
1390
 
1391
		return BasePeer::doValidate(ArticlePeer::DATABASE_NAME, ArticlePeer::TABLE_NAME, $columns);
1392
	}
1393
 
1394
	/**
1395
	 * Retrieve a single object by pkey.
1396
	 *
1397
	 * @param      int $pk the primary key.
1398
	 * @param      PropelPDO $con the connection to use
1399
	 * @return     Article
1400
	 */
1401
	public static function retrieveByPK($pk, PropelPDO $con = null)
1402
	{
1403
 
1404
		if (null !== ($obj = ArticlePeer::getInstanceFromPool((string) $pk))) {
1405
			return $obj;
1406
		}
1407
 
1408
		if ($con === null) {
1409
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
1410
		}
1411
 
1412
		$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
1413
		$criteria->add(ArticlePeer::ID, $pk);
1414
 
1415
		$v = ArticlePeer::doSelect($criteria, $con);
1416
 
1417
		return !empty($v) > 0 ? $v[0] : null;
1418
	}
1419
 
1420
	/**
1421
	 * Retrieve multiple objects by pkey.
1422
	 *
1423
	 * @param      array $pks List of primary keys
1424
	 * @param      PropelPDO $con the connection to use
1425
	 * @throws     PropelException Any exceptions caught during processing will be
1426
	 *		 rethrown wrapped into a PropelException.
1427
	 */
1428
	public static function retrieveByPKs($pks, PropelPDO $con = null)
1429
	{
1430
		if ($con === null) {
1431
			$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
1432
		}
1433
 
1434
		$objs = null;
1435
		if (empty($pks)) {
1436
			$objs = array();
1437
		} else {
1438
			$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
1439
			$criteria->add(ArticlePeer::ID, $pks, Criteria::IN);
1440
			$objs = ArticlePeer::doSelect($criteria, $con);
1441
		}
1442
		return $objs;
1443
	}
1444
 
1445
	// symfony behavior
1446
 
1447
	/**
1448
	 * Returns an array of arrays that contain columns in each unique index.
1449
	 *
1450
	 * @return array
1451
	 */
1452
	static public function getUniqueColumnNames()
1453
	{
1454
	  return array(array('title', 'category_id'));
1455
	}
1456
 
1457
	// symfony_behaviors behavior
1458
 
1459
	/**
1460
	 * Returns the name of the hook to call from inside the supplied method.
1461
	 *
1462
	 * @param string $method The calling method
1463
	 *
1464
	 * @return string A hook name for {@link sfMixer}
1465
	 *
1466
	 * @throws LogicException If the method name is not recognized
1467
	 */
1468
	static private function getMixerPreSelectHook($method)
1469
	{
1470
	  if (preg_match('/^do(Select|Count)(Join(All(Except)?)?|Stmt)?/', $method, $match))
1471
	  {
1472
	    return sprintf('BaseArticlePeer:%s:%1$s', 'Count' == $match[1] ? 'doCount' : $match[0]);
1473
	  }
1474
 
1475
	  throw new LogicException(sprintf('Unrecognized function "%s"', $method));
1476
	}
1477
 
1478
} // BaseArticlePeer
1479
 
1480
// This is the static code needed to register the TableMap for this table with the main Propel class.
1481
//
1482
BaseArticlePeer::buildTableMap();
1483