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