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 'product_i18n' table.
5
 *
6
 *
7
 *
8
 * This class was autogenerated by Propel 1.4.2 on:
9
 *
10
 * Fri Aug  5 09:39:37 2011
11
 *
12
 * @package    lib.model.om
13
 */
14
abstract class BaseProductI18nPeer {
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 = 'product_i18n';
21
 
22
	/** the related Propel class for this table */
23
	const OM_CLASS = 'ProductI18n';
24
 
25
	/** A class that can be returned by this peer. */
26
	const CLASS_DEFAULT = 'lib.model.ProductI18n';
27
 
28
	/** the related TableMap class for this table */
29
	const TM_CLASS = 'ProductI18nTableMap';
30
 
31
	/** The total number of columns. */
32
	const NUM_COLUMNS = 3;
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 = 'product_i18n.ID';
39
 
40
	/** the column name for the CULTURE field */
41
	const CULTURE = 'product_i18n.CULTURE';
42
 
43
	/** the column name for the NAME field */
44
	const NAME = 'product_i18n.NAME';
45
 
46
	/**
47
	 * An identiy map to hold any loaded instances of ProductI18n objects.
48
	 * This must be public so that other peer classes can access this when hydrating from JOIN
49
	 * queries.
50
	 * @var        array ProductI18n[]
51
	 */
52
	public static $instances = array();
53
 
54
 
55
	// symfony behavior
56
 
57
	/**
58
	 * Indicates whether the current model includes I18N.
59
	 */
60
	const IS_I18N = false;
61
 
62
	/**
63
	 * holds an array of fieldnames
64
	 *
65
	 * first dimension keys are the type constants
66
	 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
67
	 */
68
	private static $fieldNames = array (
69
		BasePeer::TYPE_PHPNAME => array ('Id', 'Culture', 'Name', ),
70
		BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'culture', 'name', ),
71
		BasePeer::TYPE_COLNAME => array (self::ID, self::CULTURE, self::NAME, ),
72
		BasePeer::TYPE_FIELDNAME => array ('id', 'culture', 'name', ),
73
		BasePeer::TYPE_NUM => array (0, 1, 2, )
74
	);
75
 
76
	/**
77
	 * holds an array of keys for quick access to the fieldnames array
78
	 *
79
	 * first dimension keys are the type constants
80
	 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
81
	 */
82
	private static $fieldKeys = array (
83
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Culture' => 1, 'Name' => 2, ),
84
		BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'culture' => 1, 'name' => 2, ),
85
		BasePeer::TYPE_COLNAME => array (self::ID => 0, self::CULTURE => 1, self::NAME => 2, ),
86
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'culture' => 1, 'name' => 2, ),
87
		BasePeer::TYPE_NUM => array (0, 1, 2, )
88
	);
89
 
90
	/**
91
	 * Translates a fieldname to another type
92
	 *
93
	 * @param      string $name field name
94
	 * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
95
	 *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
96
	 * @param      string $toType   One of the class type constants
97
	 * @return     string translated name of the field.
98
	 * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
99
	 */
100
	static public function translateFieldName($name, $fromType, $toType)
101
	{
102
		$toNames = self::getFieldNames($toType);
103
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
104
		if ($key === null) {
105
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
106
		}
107
		return $toNames[$key];
108
	}
109
 
110
	/**
111
	 * Returns an array of field names.
112
	 *
113
	 * @param      string $type The type of fieldnames to return:
114
	 *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
115
	 *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
116
	 * @return     array A list of field names
117
	 */
118
 
119
	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
120
	{
121
		if (!array_key_exists($type, self::$fieldNames)) {
122
			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.');
123
		}
124
		return self::$fieldNames[$type];
125
	}
126
 
127
	/**
128
	 * Convenience method which changes table.column to alias.column.
129
	 *
130
	 * Using this method you can maintain SQL abstraction while using column aliases.
131
	 * <code>
132
	 *		$c->addAlias("alias1", TablePeer::TABLE_NAME);
133
	 *		$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
134
	 * </code>
135
	 * @param      string $alias The alias for the current table.
136
	 * @param      string $column The column name for current table. (i.e. ProductI18nPeer::COLUMN_NAME).
137
	 * @return     string
138
	 */
139
	public static function alias($alias, $column)
140
	{
141
		return str_replace(ProductI18nPeer::TABLE_NAME.'.', $alias.'.', $column);
142
	}
143
 
144
	/**
145
	 * Add all the columns needed to create a new object.
146
	 *
147
	 * Note: any columns that were marked with lazyLoad="true" in the
148
	 * XML schema will not be added to the select list and only loaded
149
	 * on demand.
150
	 *
151
	 * @param      criteria object containing the columns to add.
152
	 * @throws     PropelException Any exceptions caught during processing will be
153
	 *		 rethrown wrapped into a PropelException.
154
	 */
155
	public static function addSelectColumns(Criteria $criteria)
156
	{
157
		$criteria->addSelectColumn(ProductI18nPeer::ID);
158
		$criteria->addSelectColumn(ProductI18nPeer::CULTURE);
159
		$criteria->addSelectColumn(ProductI18nPeer::NAME);
160
	}
161
 
162
	/**
163
	 * Returns the number of rows matching criteria.
164
	 *
165
	 * @param      Criteria $criteria
166
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
167
	 * @param      PropelPDO $con
168
	 * @return     int Number of matching rows.
169
	 */
170
	public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
171
	{
172
		// we may modify criteria, so copy it first
173
		$criteria = clone $criteria;
174
 
175
		// We need to set the primary table name, since in the case that there are no WHERE columns
176
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
177
		// tables go into the FROM clause.
178
		$criteria->setPrimaryTableName(ProductI18nPeer::TABLE_NAME);
179
 
180
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
181
			$criteria->setDistinct();
182
		}
183
 
184
		if (!$criteria->hasSelectClause()) {
185
			ProductI18nPeer::addSelectColumns($criteria);
186
		}
187
 
188
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
189
		$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
190
 
191
		if ($con === null) {
192
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
193
		}
194
		// symfony_behaviors behavior
195
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
196
		{
197
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
198
		}
199
 
200
		// BasePeer returns a PDOStatement
201
		$stmt = BasePeer::doCount($criteria, $con);
202
 
203
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
204
			$count = (int) $row[0];
205
		} else {
206
			$count = 0; // no rows returned; we infer that means 0 matches.
207
		}
208
		$stmt->closeCursor();
209
		return $count;
210
	}
211
	/**
212
	 * Method to select one object from the DB.
213
	 *
214
	 * @param      Criteria $criteria object used to create the SELECT statement.
215
	 * @param      PropelPDO $con
216
	 * @return     ProductI18n
217
	 * @throws     PropelException Any exceptions caught during processing will be
218
	 *		 rethrown wrapped into a PropelException.
219
	 */
220
	public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
221
	{
222
		$critcopy = clone $criteria;
223
		$critcopy->setLimit(1);
224
		$objects = ProductI18nPeer::doSelect($critcopy, $con);
225
		if ($objects) {
226
			return $objects[0];
227
		}
228
		return null;
229
	}
230
	/**
231
	 * Method to do selects.
232
	 *
233
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
234
	 * @param      PropelPDO $con
235
	 * @return     array Array of selected Objects
236
	 * @throws     PropelException Any exceptions caught during processing will be
237
	 *		 rethrown wrapped into a PropelException.
238
	 */
239
	public static function doSelect(Criteria $criteria, PropelPDO $con = null)
240
	{
241
		return ProductI18nPeer::populateObjects(ProductI18nPeer::doSelectStmt($criteria, $con));
242
	}
243
	/**
244
	 * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
245
	 *
246
	 * Use this method directly if you want to work with an executed statement durirectly (for example
247
	 * to perform your own object hydration).
248
	 *
249
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
250
	 * @param      PropelPDO $con The connection to use
251
	 * @throws     PropelException Any exceptions caught during processing will be
252
	 *		 rethrown wrapped into a PropelException.
253
	 * @return     PDOStatement The executed PDOStatement object.
254
	 * @see        BasePeer::doSelect()
255
	 */
256
	public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
257
	{
258
		if ($con === null) {
259
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
260
		}
261
 
262
		if (!$criteria->hasSelectClause()) {
263
			$criteria = clone $criteria;
264
			ProductI18nPeer::addSelectColumns($criteria);
265
		}
266
 
267
		// Set the correct dbName
268
		$criteria->setDbName(self::DATABASE_NAME);
269
		// symfony_behaviors behavior
270
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
271
		{
272
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
273
		}
274
 
275
 
276
		// BasePeer returns a PDOStatement
277
		return BasePeer::doSelect($criteria, $con);
278
	}
279
	/**
280
	 * Adds an object to the instance pool.
281
	 *
282
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
283
	 * from the database.  In some cases -- especially when you override doSelect*()
284
	 * methods in your stub classes -- you may need to explicitly add objects
285
	 * to the cache in order to ensure that the same objects are always returned by doSelect*()
286
	 * and retrieveByPK*() calls.
287
	 *
288
	 * @param      ProductI18n $value A ProductI18n object.
289
	 * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
290
	 */
291
	public static function addInstanceToPool(ProductI18n $obj, $key = null)
292
	{
293
		if (Propel::isInstancePoolingEnabled()) {
294
			if ($key === null) {
295
				$key = serialize(array((string) $obj->getId(), (string) $obj->getCulture()));
296
			} // if key === null
297
			self::$instances[$key] = $obj;
298
		}
299
	}
300
 
301
	/**
302
	 * Removes an object from the instance pool.
303
	 *
304
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
305
	 * from the database.  In some cases -- especially when you override doDelete
306
	 * methods in your stub classes -- you may need to explicitly remove objects
307
	 * from the cache in order to prevent returning objects that no longer exist.
308
	 *
309
	 * @param      mixed $value A ProductI18n object or a primary key value.
310
	 */
311
	public static function removeInstanceFromPool($value)
312
	{
313
		if (Propel::isInstancePoolingEnabled() && $value !== null) {
314
			if (is_object($value) && $value instanceof ProductI18n) {
315
				$key = serialize(array((string) $value->getId(), (string) $value->getCulture()));
316
			} elseif (is_array($value) && count($value) === 2) {
317
				// assume we've been passed a primary key
318
				$key = serialize(array((string) $value[0], (string) $value[1]));
319
			} else {
320
				$e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or ProductI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
321
				throw $e;
322
			}
323
 
324
			unset(self::$instances[$key]);
325
		}
326
	} // removeInstanceFromPool()
327
 
328
	/**
329
	 * 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.
330
	 *
331
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
332
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
333
	 *
334
	 * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
335
	 * @return     ProductI18n Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
336
	 * @see        getPrimaryKeyHash()
337
	 */
338
	public static function getInstanceFromPool($key)
339
	{
340
		if (Propel::isInstancePoolingEnabled()) {
341
			if (isset(self::$instances[$key])) {
342
				return self::$instances[$key];
343
			}
344
		}
345
		return null; // just to be explicit
346
	}
347
 
348
	/**
349
	 * Clear the instance pool.
350
	 *
351
	 * @return     void
352
	 */
353
	public static function clearInstancePool()
354
	{
355
		self::$instances = array();
356
	}
357
 
358
	/**
359
	 * Method to invalidate the instance pool of all tables related to product_i18n
360
	 * by a foreign key with ON DELETE CASCADE
361
	 */
362
	public static function clearRelatedInstancePool()
363
	{
364
	}
365
 
366
	/**
367
	 * 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.
368
	 *
369
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
370
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
371
	 *
372
	 * @param      array $row PropelPDO resultset row.
373
	 * @param      int $startcol The 0-based offset for reading from the resultset row.
374
	 * @return     string A string version of PK or NULL if the components of primary key in result array are all null.
375
	 */
376
	public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
377
	{
378
		// If the PK cannot be derived from the row, return NULL.
379
		if ($row[$startcol] === null && $row[$startcol + 1] === null) {
380
			return null;
381
		}
382
		return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
383
	}
384
 
385
	/**
386
	 * The returned array will contain objects of the default type or
387
	 * objects that inherit from the default.
388
	 *
389
	 * @throws     PropelException Any exceptions caught during processing will be
390
	 *		 rethrown wrapped into a PropelException.
391
	 */
392
	public static function populateObjects(PDOStatement $stmt)
393
	{
394
		$results = array();
395
 
396
		// set the class once to avoid overhead in the loop
397
		$cls = ProductI18nPeer::getOMClass(false);
398
		// populate the object(s)
399
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
400
			$key = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0);
401
			if (null !== ($obj = ProductI18nPeer::getInstanceFromPool($key))) {
402
				// We no longer rehydrate the object, since this can cause data loss.
403
				// See http://propel.phpdb.org/trac/ticket/509
404
				// $obj->hydrate($row, 0, true); // rehydrate
405
				$results[] = $obj;
406
			} else {
407
				$obj = new $cls();
408
				$obj->hydrate($row);
409
				$results[] = $obj;
410
				ProductI18nPeer::addInstanceToPool($obj, $key);
411
			} // if key exists
412
		}
413
		$stmt->closeCursor();
414
		return $results;
415
	}
416
 
417
	/**
418
	 * Returns the number of rows matching criteria, joining the related Product table
419
	 *
420
	 * @param      Criteria $criteria
421
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
422
	 * @param      PropelPDO $con
423
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
424
	 * @return     int Number of matching rows.
425
	 */
426
	public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
427
	{
428
		// we're going to modify criteria, so copy it first
429
		$criteria = clone $criteria;
430
 
431
		// We need to set the primary table name, since in the case that there are no WHERE columns
432
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
433
		// tables go into the FROM clause.
434
		$criteria->setPrimaryTableName(ProductI18nPeer::TABLE_NAME);
435
 
436
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
437
			$criteria->setDistinct();
438
		}
439
 
440
		if (!$criteria->hasSelectClause()) {
441
			ProductI18nPeer::addSelectColumns($criteria);
442
		}
443
 
444
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
445
 
446
		// Set the correct dbName
447
		$criteria->setDbName(self::DATABASE_NAME);
448
 
449
		if ($con === null) {
450
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
451
		}
452
 
453
		$criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior);
454
 
455
		// symfony_behaviors behavior
456
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
457
		{
458
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
459
		}
460
 
461
		$stmt = BasePeer::doCount($criteria, $con);
462
 
463
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
464
			$count = (int) $row[0];
465
		} else {
466
			$count = 0; // no rows returned; we infer that means 0 matches.
467
		}
468
		$stmt->closeCursor();
469
		return $count;
470
	}
471
 
472
 
473
	/**
474
	 * Selects a collection of ProductI18n objects pre-filled with their Product objects.
475
	 * @param      Criteria  $criteria
476
	 * @param      PropelPDO $con
477
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
478
	 * @return     array Array of ProductI18n objects.
479
	 * @throws     PropelException Any exceptions caught during processing will be
480
	 *		 rethrown wrapped into a PropelException.
481
	 */
482
	public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
483
	{
484
		$criteria = clone $criteria;
485
 
486
		// Set the correct dbName if it has not been overridden
487
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
488
			$criteria->setDbName(self::DATABASE_NAME);
489
		}
490
 
491
		ProductI18nPeer::addSelectColumns($criteria);
492
		$startcol = (ProductI18nPeer::NUM_COLUMNS - ProductI18nPeer::NUM_LAZY_LOAD_COLUMNS);
493
		ProductPeer::addSelectColumns($criteria);
494
 
495
		$criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior);
496
 
497
		// symfony_behaviors behavior
498
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
499
		{
500
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
501
		}
502
 
503
		$stmt = BasePeer::doSelect($criteria, $con);
504
		$results = array();
505
 
506
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
507
			$key1 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0);
508
			if (null !== ($obj1 = ProductI18nPeer::getInstanceFromPool($key1))) {
509
				// We no longer rehydrate the object, since this can cause data loss.
510
				// See http://propel.phpdb.org/trac/ticket/509
511
				// $obj1->hydrate($row, 0, true); // rehydrate
512
			} else {
513
 
514
				$cls = ProductI18nPeer::getOMClass(false);
515
 
516
				$obj1 = new $cls();
517
				$obj1->hydrate($row);
518
				ProductI18nPeer::addInstanceToPool($obj1, $key1);
519
			} // if $obj1 already loaded
520
 
521
			$key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
522
			if ($key2 !== null) {
523
				$obj2 = ProductPeer::getInstanceFromPool($key2);
524
				if (!$obj2) {
525
 
526
					$cls = ProductPeer::getOMClass(false);
527
 
528
					$obj2 = new $cls();
529
					$obj2->hydrate($row, $startcol);
530
					ProductPeer::addInstanceToPool($obj2, $key2);
531
				} // if obj2 already loaded
532
 
533
				// Add the $obj1 (ProductI18n) to $obj2 (Product)
534
				$obj2->addTranslation($obj1);
535
 
536
			} // if joined row was not null
537
 
538
			$results[] = $obj1;
539
		}
540
		$stmt->closeCursor();
541
		return $results;
542
	}
543
 
544
 
545
	/**
546
	 * Returns the number of rows matching criteria, joining all related tables
547
	 *
548
	 * @param      Criteria $criteria
549
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
550
	 * @param      PropelPDO $con
551
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
552
	 * @return     int Number of matching rows.
553
	 */
554
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
555
	{
556
		// we're going to modify criteria, so copy it first
557
		$criteria = clone $criteria;
558
 
559
		// We need to set the primary table name, since in the case that there are no WHERE columns
560
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
561
		// tables go into the FROM clause.
562
		$criteria->setPrimaryTableName(ProductI18nPeer::TABLE_NAME);
563
 
564
		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
565
			$criteria->setDistinct();
566
		}
567
 
568
		if (!$criteria->hasSelectClause()) {
569
			ProductI18nPeer::addSelectColumns($criteria);
570
		}
571
 
572
		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
573
 
574
		// Set the correct dbName
575
		$criteria->setDbName(self::DATABASE_NAME);
576
 
577
		if ($con === null) {
578
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
579
		}
580
 
581
		$criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior);
582
 
583
		// symfony_behaviors behavior
584
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
585
		{
586
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
587
		}
588
 
589
		$stmt = BasePeer::doCount($criteria, $con);
590
 
591
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
592
			$count = (int) $row[0];
593
		} else {
594
			$count = 0; // no rows returned; we infer that means 0 matches.
595
		}
596
		$stmt->closeCursor();
597
		return $count;
598
	}
599
 
600
	/**
601
	 * Selects a collection of ProductI18n objects pre-filled with all related objects.
602
	 *
603
	 * @param      Criteria  $criteria
604
	 * @param      PropelPDO $con
605
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
606
	 * @return     array Array of ProductI18n objects.
607
	 * @throws     PropelException Any exceptions caught during processing will be
608
	 *		 rethrown wrapped into a PropelException.
609
	 */
610
	public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
611
	{
612
		$criteria = clone $criteria;
613
 
614
		// Set the correct dbName if it has not been overridden
615
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
616
			$criteria->setDbName(self::DATABASE_NAME);
617
		}
618
 
619
		ProductI18nPeer::addSelectColumns($criteria);
620
		$startcol2 = (ProductI18nPeer::NUM_COLUMNS - ProductI18nPeer::NUM_LAZY_LOAD_COLUMNS);
621
 
622
		ProductPeer::addSelectColumns($criteria);
623
		$startcol3 = $startcol2 + (ProductPeer::NUM_COLUMNS - ProductPeer::NUM_LAZY_LOAD_COLUMNS);
624
 
625
		$criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior);
626
 
627
		// symfony_behaviors behavior
628
		foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
629
		{
630
		  call_user_func($sf_hook, 'BaseProductI18nPeer', $criteria, $con);
631
		}
632
 
633
		$stmt = BasePeer::doSelect($criteria, $con);
634
		$results = array();
635
 
636
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
637
			$key1 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0);
638
			if (null !== ($obj1 = ProductI18nPeer::getInstanceFromPool($key1))) {
639
				// We no longer rehydrate the object, since this can cause data loss.
640
				// See http://propel.phpdb.org/trac/ticket/509
641
				// $obj1->hydrate($row, 0, true); // rehydrate
642
			} else {
643
				$cls = ProductI18nPeer::getOMClass(false);
644
 
645
				$obj1 = new $cls();
646
				$obj1->hydrate($row);
647
				ProductI18nPeer::addInstanceToPool($obj1, $key1);
648
			} // if obj1 already loaded
649
 
650
			// Add objects for joined Product rows
651
 
652
			$key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
653
			if ($key2 !== null) {
654
				$obj2 = ProductPeer::getInstanceFromPool($key2);
655
				if (!$obj2) {
656
 
657
					$cls = ProductPeer::getOMClass(false);
658
 
659
					$obj2 = new $cls();
660
					$obj2->hydrate($row, $startcol2);
661
					ProductPeer::addInstanceToPool($obj2, $key2);
662
				} // if obj2 loaded
663
 
664
				// Add the $obj1 (ProductI18n) to the collection in $obj2 (Product)
665
				$obj2->addTranslation($obj1);
666
			} // if joined row not null
667
 
668
			$results[] = $obj1;
669
		}
670
		$stmt->closeCursor();
671
		return $results;
672
	}
673
 
674
	/**
675
	 * Returns the TableMap related to this peer.
676
	 * This method is not needed for general use but a specific application could have a need.
677
	 * @return     TableMap
678
	 * @throws     PropelException Any exceptions caught during processing will be
679
	 *		 rethrown wrapped into a PropelException.
680
	 */
681
	public static function getTableMap()
682
	{
683
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
684
	}
685
 
686
	/**
687
	 * Add a TableMap instance to the database for this peer class.
688
	 */
689
	public static function buildTableMap()
690
	{
691
	  $dbMap = Propel::getDatabaseMap(BaseProductI18nPeer::DATABASE_NAME);
692
	  if (!$dbMap->hasTable(BaseProductI18nPeer::TABLE_NAME))
693
	  {
694
	    $dbMap->addTableObject(new ProductI18nTableMap());
695
	  }
696
	}
697
 
698
	/**
699
	 * The class that the Peer will make instances of.
700
	 *
701
	 * If $withPrefix is true, the returned path
702
	 * uses a dot-path notation which is tranalted into a path
703
	 * relative to a location on the PHP include_path.
704
	 * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
705
	 *
706
	 * @param      boolean  Whether or not to return the path wit hthe class name
707
	 * @return     string path.to.ClassName
708
	 */
709
	public static function getOMClass($withPrefix = true)
710
	{
711
		return $withPrefix ? ProductI18nPeer::CLASS_DEFAULT : ProductI18nPeer::OM_CLASS;
712
	}
713
 
714
	/**
715
	 * Method perform an INSERT on the database, given a ProductI18n or Criteria object.
716
	 *
717
	 * @param      mixed $values Criteria or ProductI18n object containing data that is used to create the INSERT statement.
718
	 * @param      PropelPDO $con the PropelPDO connection to use
719
	 * @return     mixed The new primary key.
720
	 * @throws     PropelException Any exceptions caught during processing will be
721
	 *		 rethrown wrapped into a PropelException.
722
	 */
723
	public static function doInsert($values, PropelPDO $con = null)
724
	{
725
    // symfony_behaviors behavior
726
    foreach (sfMixer::getCallables('BaseProductI18nPeer:doInsert:pre') as $sf_hook)
727
    {
728
      if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseProductI18nPeer', $values, $con))
729
      {
730
        return $sf_hook_retval;
731
      }
732
    }
733
 
734
		if ($con === null) {
735
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
736
		}
737
 
738
		if ($values instanceof Criteria) {
739
			$criteria = clone $values; // rename for clarity
740
		} else {
741
			$criteria = $values->buildCriteria(); // build Criteria from ProductI18n object
742
		}
743
 
744
 
745
		// Set the correct dbName
746
		$criteria->setDbName(self::DATABASE_NAME);
747
 
748
		try {
749
			// use transaction because $criteria could contain info
750
			// for more than one table (I guess, conceivably)
751
			$con->beginTransaction();
752
			$pk = BasePeer::doInsert($criteria, $con);
753
			$con->commit();
754
		} catch(PropelException $e) {
755
			$con->rollBack();
756
			throw $e;
757
		}
758
 
759
    // symfony_behaviors behavior
760
    foreach (sfMixer::getCallables('BaseProductI18nPeer:doInsert:post') as $sf_hook)
761
    {
762
      call_user_func($sf_hook, 'BaseProductI18nPeer', $values, $con, $pk);
763
    }
764
 
765
		return $pk;
766
	}
767
 
768
	/**
769
	 * Method perform an UPDATE on the database, given a ProductI18n or Criteria object.
770
	 *
771
	 * @param      mixed $values Criteria or ProductI18n object containing data that is used to create the UPDATE statement.
772
	 * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
773
	 * @return     int The number of affected rows (if supported by underlying database driver).
774
	 * @throws     PropelException Any exceptions caught during processing will be
775
	 *		 rethrown wrapped into a PropelException.
776
	 */
777
	public static function doUpdate($values, PropelPDO $con = null)
778
	{
779
    // symfony_behaviors behavior
780
    foreach (sfMixer::getCallables('BaseProductI18nPeer:doUpdate:pre') as $sf_hook)
781
    {
782
      if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseProductI18nPeer', $values, $con))
783
      {
784
        return $sf_hook_retval;
785
      }
786
    }
787
 
788
		if ($con === null) {
789
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
790
		}
791
 
792
		$selectCriteria = new Criteria(self::DATABASE_NAME);
793
 
794
		if ($values instanceof Criteria) {
795
			$criteria = clone $values; // rename for clarity
796
 
797
			$comparison = $criteria->getComparison(ProductI18nPeer::ID);
798
			$selectCriteria->add(ProductI18nPeer::ID, $criteria->remove(ProductI18nPeer::ID), $comparison);
799
 
800
			$comparison = $criteria->getComparison(ProductI18nPeer::CULTURE);
801
			$selectCriteria->add(ProductI18nPeer::CULTURE, $criteria->remove(ProductI18nPeer::CULTURE), $comparison);
802
 
803
		} else { // $values is ProductI18n object
804
			$criteria = $values->buildCriteria(); // gets full criteria
805
			$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
806
		}
807
 
808
		// set the correct dbName
809
		$criteria->setDbName(self::DATABASE_NAME);
810
 
811
		$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
812
 
813
    // symfony_behaviors behavior
814
    foreach (sfMixer::getCallables('BaseProductI18nPeer:doUpdate:post') as $sf_hook)
815
    {
816
      call_user_func($sf_hook, 'BaseProductI18nPeer', $values, $con, $ret);
817
    }
818
 
819
    return $ret;
820
	}
821
 
822
	/**
823
	 * Method to DELETE all rows from the product_i18n table.
824
	 *
825
	 * @return     int The number of affected rows (if supported by underlying database driver).
826
	 */
827
	public static function doDeleteAll($con = null)
828
	{
829
		if ($con === null) {
830
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
831
		}
832
		$affectedRows = 0; // initialize var to track total num of affected rows
833
		try {
834
			// use transaction because $criteria could contain info
835
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
836
			$con->beginTransaction();
837
			$affectedRows += BasePeer::doDeleteAll(ProductI18nPeer::TABLE_NAME, $con);
838
			// Because this db requires some delete cascade/set null emulation, we have to
839
			// clear the cached instance *after* the emulation has happened (since
840
			// instances get re-added by the select statement contained therein).
841
			ProductI18nPeer::clearInstancePool();
842
			ProductI18nPeer::clearRelatedInstancePool();
843
			$con->commit();
844
			return $affectedRows;
845
		} catch (PropelException $e) {
846
			$con->rollBack();
847
			throw $e;
848
		}
849
	}
850
 
851
	/**
852
	 * Method perform a DELETE on the database, given a ProductI18n or Criteria object OR a primary key value.
853
	 *
854
	 * @param      mixed $values Criteria or ProductI18n object or primary key or array of primary keys
855
	 *              which is used to create the DELETE statement
856
	 * @param      PropelPDO $con the connection to use
857
	 * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
858
	 *				if supported by native driver or if emulated using Propel.
859
	 * @throws     PropelException Any exceptions caught during processing will be
860
	 *		 rethrown wrapped into a PropelException.
861
	 */
862
	 public static function doDelete($values, PropelPDO $con = null)
863
	 {
864
		if ($con === null) {
865
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
866
		}
867
 
868
		if ($values instanceof Criteria) {
869
			// invalidate the cache for all objects of this type, since we have no
870
			// way of knowing (without running a query) what objects should be invalidated
871
			// from the cache based on this Criteria.
872
			ProductI18nPeer::clearInstancePool();
873
			// rename for clarity
874
			$criteria = clone $values;
875
		} elseif ($values instanceof ProductI18n) { // it's a model object
876
			// invalidate the cache for this single object
877
			ProductI18nPeer::removeInstanceFromPool($values);
878
			// create criteria based on pk values
879
			$criteria = $values->buildPkeyCriteria();
880
		} else { // it's a primary key, or an array of pks
881
			$criteria = new Criteria(self::DATABASE_NAME);
882
			// primary key is composite; we therefore, expect
883
			// the primary key passed to be an array of pkey values
884
			if (count($values) == count($values, COUNT_RECURSIVE)) {
885
				// array is not multi-dimensional
886
				$values = array($values);
887
			}
888
			foreach ($values as $value) {
889
				$criterion = $criteria->getNewCriterion(ProductI18nPeer::ID, $value[0]);
890
				$criterion->addAnd($criteria->getNewCriterion(ProductI18nPeer::CULTURE, $value[1]));
891
				$criteria->addOr($criterion);
892
				// we can invalidate the cache for this single PK
893
				ProductI18nPeer::removeInstanceFromPool($value);
894
			}
895
		}
896
 
897
		// Set the correct dbName
898
		$criteria->setDbName(self::DATABASE_NAME);
899
 
900
		$affectedRows = 0; // initialize var to track total num of affected rows
901
 
902
		try {
903
			// use transaction because $criteria could contain info
904
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
905
			$con->beginTransaction();
906
 
907
			$affectedRows += BasePeer::doDelete($criteria, $con);
908
			ProductI18nPeer::clearRelatedInstancePool();
909
			$con->commit();
910
			return $affectedRows;
911
		} catch (PropelException $e) {
912
			$con->rollBack();
913
			throw $e;
914
		}
915
	}
916
 
917
	/**
918
	 * Validates all modified columns of given ProductI18n object.
919
	 * If parameter $columns is either a single column name or an array of column names
920
	 * than only those columns are validated.
921
	 *
922
	 * NOTICE: This does not apply to primary or foreign keys for now.
923
	 *
924
	 * @param      ProductI18n $obj The object to validate.
925
	 * @param      mixed $cols Column name or array of column names.
926
	 *
927
	 * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
928
	 */
929
	public static function doValidate(ProductI18n $obj, $cols = null)
930
	{
931
		$columns = array();
932
 
933
		if ($cols) {
934
			$dbMap = Propel::getDatabaseMap(ProductI18nPeer::DATABASE_NAME);
935
			$tableMap = $dbMap->getTable(ProductI18nPeer::TABLE_NAME);
936
 
937
			if (! is_array($cols)) {
938
				$cols = array($cols);
939
			}
940
 
941
			foreach ($cols as $colName) {
942
				if ($tableMap->containsColumn($colName)) {
943
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
944
					$columns[$colName] = $obj->$get();
945
				}
946
			}
947
		} else {
948
 
949
		}
950
 
951
		return BasePeer::doValidate(ProductI18nPeer::DATABASE_NAME, ProductI18nPeer::TABLE_NAME, $columns);
952
	}
953
 
954
	/**
955
	 * Retrieve object using using composite pkey values.
956
	 * @param      int $id
957
	 * @param      string $culture
958
	 * @param      PropelPDO $con
959
	 * @return     ProductI18n
960
	 */
961
	public static function retrieveByPK($id, $culture, PropelPDO $con = null) {
962
		$key = serialize(array((string) $id, (string) $culture));
963
 		if (null !== ($obj = ProductI18nPeer::getInstanceFromPool($key))) {
964
 			return $obj;
965
		}
966
 
967
		if ($con === null) {
968
			$con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
969
		}
970
		$criteria = new Criteria(ProductI18nPeer::DATABASE_NAME);
971
		$criteria->add(ProductI18nPeer::ID, $id);
972
		$criteria->add(ProductI18nPeer::CULTURE, $culture);
973
		$v = ProductI18nPeer::doSelect($criteria, $con);
974
 
975
		return !empty($v) ? $v[0] : null;
976
	}
977
	// symfony behavior
978
 
979
	/**
980
	 * Returns an array of arrays that contain columns in each unique index.
981
	 *
982
	 * @return array
983
	 */
984
	static public function getUniqueColumnNames()
985
	{
986
	  return array();
987
	}
988
 
989
	// symfony_behaviors behavior
990
 
991
	/**
992
	 * Returns the name of the hook to call from inside the supplied method.
993
	 *
994
	 * @param string $method The calling method
995
	 *
996
	 * @return string A hook name for {@link sfMixer}
997
	 *
998
	 * @throws LogicException If the method name is not recognized
999
	 */
1000
	static private function getMixerPreSelectHook($method)
1001
	{
1002
	  if (preg_match('/^do(Select|Count)(Join(All(Except)?)?|Stmt)?/', $method, $match))
1003
	  {
1004
	    return sprintf('BaseProductI18nPeer:%s:%1$s', 'Count' == $match[1] ? 'doCount' : $match[0]);
1005
	  }
1006
 
1007
	  throw new LogicException(sprintf('Unrecognized function "%s"', $method));
1008
	}
1009
 
1010
} // BaseProductI18nPeer
1011
 
1012
// This is the static code needed to register the TableMap for this table with the main Propel class.
1013
//
1014
BaseProductI18nPeer::buildTableMap();
1015