| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
abstract class BaseCommentPeer { |
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
const DATABASE_NAME = 'propel'; |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
const TABLE_NAME = 'comment'; |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
const CLASS_DEFAULT = 'lib.model.Comment'; |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
const NUM_COLUMNS = 5; |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
const NUM_LAZY_LOAD_COLUMNS = 0; |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
const ID = 'comment.ID'; |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
const ARTICLE_ID = 'comment.ARTICLE_ID'; |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
const AUTHOR = 'comment.AUTHOR'; |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
const CONTENT = 'comment.CONTENT'; |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
const CREATED_AT = 'comment.CREATED_AT'; |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
private static $phpNameMap = null; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
private static $fieldNames = array ( |
|---|
| 43 |
BasePeer::TYPE_PHPNAME => array ('Id', 'ArticleId', 'Author', 'Content', 'CreatedAt', ), |
|---|
| 44 |
BasePeer::TYPE_COLNAME => array (CommentPeer::ID, CommentPeer::ARTICLE_ID, CommentPeer::AUTHOR, CommentPeer::CONTENT, CommentPeer::CREATED_AT, ), |
|---|
| 45 |
BasePeer::TYPE_FIELDNAME => array ('id', 'article_id', 'author', 'content', 'created_at', ), |
|---|
| 46 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) |
|---|
| 47 |
); |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
private static $fieldKeys = array ( |
|---|
| 51 |
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ArticleId' => 1, 'Author' => 2, 'Content' => 3, 'CreatedAt' => 4, ), |
|---|
| 52 |
BasePeer::TYPE_COLNAME => array (CommentPeer::ID => 0, CommentPeer::ARTICLE_ID => 1, CommentPeer::AUTHOR => 2, CommentPeer::CONTENT => 3, CommentPeer::CREATED_AT => 4, ), |
|---|
| 53 |
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'article_id' => 1, 'author' => 2, 'content' => 3, 'created_at' => 4, ), |
|---|
| 54 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) |
|---|
| 55 |
); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
public static function getMapBuilder() |
|---|
| 59 |
{ |
|---|
| 60 |
include_once 'lib/model/map/CommentMapBuilder.php'; |
|---|
| 61 |
return BasePeer::getMapBuilder('lib.model.map.CommentMapBuilder'); |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
public static function getPhpNameMap() |
|---|
| 65 |
{ |
|---|
| 66 |
if (self::$phpNameMap === null) { |
|---|
| 67 |
$map = CommentPeer::getTableMap(); |
|---|
| 68 |
$columns = $map->getColumns(); |
|---|
| 69 |
$nameMap = array(); |
|---|
| 70 |
foreach ($columns as $column) { |
|---|
| 71 |
$nameMap[$column->getPhpName()] = $column->getColumnName(); |
|---|
| 72 |
} |
|---|
| 73 |
self::$phpNameMap = $nameMap; |
|---|
| 74 |
} |
|---|
| 75 |
return self::$phpNameMap; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
static public function translateFieldName($name, $fromType, $toType) |
|---|
| 79 |
{ |
|---|
| 80 |
$toNames = self::getFieldNames($toType); |
|---|
| 81 |
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; |
|---|
| 82 |
if ($key === null) { |
|---|
| 83 |
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); |
|---|
| 84 |
} |
|---|
| 85 |
return $toNames[$key]; |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) |
|---|
| 91 |
{ |
|---|
| 92 |
if (!array_key_exists($type, self::$fieldNames)) { |
|---|
| 93 |
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); |
|---|
| 94 |
} |
|---|
| 95 |
return self::$fieldNames[$type]; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
public static function alias($alias, $column) |
|---|
| 100 |
{ |
|---|
| 101 |
return str_replace(CommentPeer::TABLE_NAME.'.', $alias.'.', $column); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
public static function addSelectColumns(Criteria $criteria) |
|---|
| 106 |
{ |
|---|
| 107 |
|
|---|
| 108 |
$criteria->addSelectColumn(CommentPeer::ID); |
|---|
| 109 |
|
|---|
| 110 |
$criteria->addSelectColumn(CommentPeer::ARTICLE_ID); |
|---|
| 111 |
|
|---|
| 112 |
$criteria->addSelectColumn(CommentPeer::AUTHOR); |
|---|
| 113 |
|
|---|
| 114 |
$criteria->addSelectColumn(CommentPeer::CONTENT); |
|---|
| 115 |
|
|---|
| 116 |
$criteria->addSelectColumn(CommentPeer::CREATED_AT); |
|---|
| 117 |
|
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
const COUNT = 'COUNT(comment.ID)'; |
|---|
| 121 |
const COUNT_DISTINCT = 'COUNT(DISTINCT comment.ID)'; |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
public static function doCount(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 125 |
{ |
|---|
| 126 |
$criteria = clone $criteria; |
|---|
| 127 |
|
|---|
| 128 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 129 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 130 |
$criteria->addSelectColumn(CommentPeer::COUNT_DISTINCT); |
|---|
| 131 |
} else { |
|---|
| 132 |
$criteria->addSelectColumn(CommentPeer::COUNT); |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 136 |
{ |
|---|
| 137 |
$criteria->addSelectColumn($column); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
$rs = CommentPeer::doSelectRS($criteria, $con); |
|---|
| 141 |
if ($rs->next()) { |
|---|
| 142 |
return $rs->getInt(1); |
|---|
| 143 |
} else { |
|---|
| 144 |
return 0; |
|---|
| 145 |
} |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
public static function doSelectOne(Criteria $criteria, $con = null) |
|---|
| 149 |
{ |
|---|
| 150 |
$critcopy = clone $criteria; |
|---|
| 151 |
$critcopy->setLimit(1); |
|---|
| 152 |
$objects = CommentPeer::doSelect($critcopy, $con); |
|---|
| 153 |
if ($objects) { |
|---|
| 154 |
return $objects[0]; |
|---|
| 155 |
} |
|---|
| 156 |
return null; |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
public static function doSelect(Criteria $criteria, $con = null) |
|---|
| 160 |
{ |
|---|
| 161 |
return CommentPeer::populateObjects(CommentPeer::doSelectRS($criteria, $con)); |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
public static function doSelectRS(Criteria $criteria, $con = null) |
|---|
| 165 |
{ |
|---|
| 166 |
if ($con === null) { |
|---|
| 167 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
if (!$criteria->getSelectColumns()) { |
|---|
| 171 |
$criteria = clone $criteria; |
|---|
| 172 |
CommentPeer::addSelectColumns($criteria); |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 176 |
|
|---|
| 177 |
return BasePeer::doSelect($criteria, $con); |
|---|
| 178 |
} |
|---|
| 179 |
|
|---|
| 180 |
public static function populateObjects(ResultSet $rs) |
|---|
| 181 |
{ |
|---|
| 182 |
$results = array(); |
|---|
| 183 |
|
|---|
| 184 |
$cls = CommentPeer::getOMClass(); |
|---|
| 185 |
$cls = Propel::import($cls); |
|---|
| 186 |
while($rs->next()) { |
|---|
| 187 |
|
|---|
| 188 |
$obj = new $cls(); |
|---|
| 189 |
$obj->hydrate($rs); |
|---|
| 190 |
$results[] = $obj; |
|---|
| 191 |
|
|---|
| 192 |
} |
|---|
| 193 |
return $results; |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
public static function doCountJoinArticle(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 198 |
{ |
|---|
| 199 |
$criteria = clone $criteria; |
|---|
| 200 |
|
|---|
| 201 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 202 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 203 |
$criteria->addSelectColumn(CommentPeer::COUNT_DISTINCT); |
|---|
| 204 |
} else { |
|---|
| 205 |
$criteria->addSelectColumn(CommentPeer::COUNT); |
|---|
| 206 |
} |
|---|
| 207 |
|
|---|
| 208 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 209 |
{ |
|---|
| 210 |
$criteria->addSelectColumn($column); |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
$criteria->addJoin(CommentPeer::ARTICLE_ID, ArticlePeer::ID); |
|---|
| 214 |
|
|---|
| 215 |
$rs = CommentPeer::doSelectRS($criteria, $con); |
|---|
| 216 |
if ($rs->next()) { |
|---|
| 217 |
return $rs->getInt(1); |
|---|
| 218 |
} else { |
|---|
| 219 |
return 0; |
|---|
| 220 |
} |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
public static function doSelectJoinArticle(Criteria $c, $con = null) |
|---|
| 226 |
{ |
|---|
| 227 |
$c = clone $c; |
|---|
| 228 |
|
|---|
| 229 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 230 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
CommentPeer::addSelectColumns($c); |
|---|
| 234 |
$startcol = (CommentPeer::NUM_COLUMNS - CommentPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 235 |
ArticlePeer::addSelectColumns($c); |
|---|
| 236 |
|
|---|
| 237 |
$c->addJoin(CommentPeer::ARTICLE_ID, ArticlePeer::ID); |
|---|
| 238 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 239 |
$results = array(); |
|---|
| 240 |
|
|---|
| 241 |
while($rs->next()) { |
|---|
| 242 |
|
|---|
| 243 |
$omClass = CommentPeer::getOMClass(); |
|---|
| 244 |
|
|---|
| 245 |
$cls = Propel::import($omClass); |
|---|
| 246 |
$obj1 = new $cls(); |
|---|
| 247 |
$obj1->hydrate($rs); |
|---|
| 248 |
|
|---|
| 249 |
$omClass = ArticlePeer::getOMClass(); |
|---|
| 250 |
|
|---|
| 251 |
$cls = Propel::import($omClass); |
|---|
| 252 |
$obj2 = new $cls(); |
|---|
| 253 |
$obj2->hydrate($rs, $startcol); |
|---|
| 254 |
|
|---|
| 255 |
$newObject = true; |
|---|
| 256 |
foreach($results as $temp_obj1) { |
|---|
| 257 |
$temp_obj2 = $temp_obj1->getArticle(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 258 |
$newObject = false; |
|---|
| 259 |
$temp_obj2->addComment($obj1); break; |
|---|
| 260 |
} |
|---|
| 261 |
} |
|---|
| 262 |
if ($newObject) { |
|---|
| 263 |
$obj2->initComments(); |
|---|
| 264 |
$obj2->addComment($obj1); } |
|---|
| 265 |
$results[] = $obj1; |
|---|
| 266 |
} |
|---|
| 267 |
return $results; |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 273 |
{ |
|---|
| 274 |
$criteria = clone $criteria; |
|---|
| 275 |
|
|---|
| 276 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 277 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 278 |
$criteria->addSelectColumn(CommentPeer::COUNT_DISTINCT); |
|---|
| 279 |
} else { |
|---|
| 280 |
$criteria->addSelectColumn(CommentPeer::COUNT); |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 284 |
{ |
|---|
| 285 |
$criteria->addSelectColumn($column); |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
$criteria->addJoin(CommentPeer::ARTICLE_ID, ArticlePeer::ID); |
|---|
| 289 |
|
|---|
| 290 |
$rs = CommentPeer::doSelectRS($criteria, $con); |
|---|
| 291 |
if ($rs->next()) { |
|---|
| 292 |
return $rs->getInt(1); |
|---|
| 293 |
} else { |
|---|
| 294 |
return 0; |
|---|
| 295 |
} |
|---|
| 296 |
} |
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
public static function doSelectJoinAll(Criteria $c, $con = null) |
|---|
| 301 |
{ |
|---|
| 302 |
$c = clone $c; |
|---|
| 303 |
|
|---|
| 304 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 305 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
CommentPeer::addSelectColumns($c); |
|---|
| 309 |
$startcol2 = (CommentPeer::NUM_COLUMNS - CommentPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 310 |
|
|---|
| 311 |
ArticlePeer::addSelectColumns($c); |
|---|
| 312 |
$startcol3 = $startcol2 + ArticlePeer::NUM_COLUMNS; |
|---|
| 313 |
|
|---|
| 314 |
$c->addJoin(CommentPeer::ARTICLE_ID, ArticlePeer::ID); |
|---|
| 315 |
|
|---|
| 316 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 317 |
$results = array(); |
|---|
| 318 |
|
|---|
| 319 |
while($rs->next()) { |
|---|
| 320 |
|
|---|
| 321 |
$omClass = CommentPeer::getOMClass(); |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
$cls = Propel::import($omClass); |
|---|
| 325 |
$obj1 = new $cls(); |
|---|
| 326 |
$obj1->hydrate($rs); |
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
$omClass = ArticlePeer::getOMClass(); |
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
$cls = Propel::import($omClass); |
|---|
| 334 |
$obj2 = new $cls(); |
|---|
| 335 |
$obj2->hydrate($rs, $startcol2); |
|---|
| 336 |
|
|---|
| 337 |
$newObject = true; |
|---|
| 338 |
for ($j=0, $resCount=count($results); $j < $resCount; $j++) { |
|---|
| 339 |
$temp_obj1 = $results[$j]; |
|---|
| 340 |
$temp_obj2 = $temp_obj1->getArticle(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 341 |
$newObject = false; |
|---|
| 342 |
$temp_obj2->addComment($obj1); break; |
|---|
| 343 |
} |
|---|
| 344 |
} |
|---|
| 345 |
|
|---|
| 346 |
if ($newObject) { |
|---|
| 347 |
$obj2->initComments(); |
|---|
| 348 |
$obj2->addComment($obj1); |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
$results[] = $obj1; |
|---|
| 352 |
} |
|---|
| 353 |
return $results; |
|---|
| 354 |
} |
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
public static function getTableMap() |
|---|
| 358 |
{ |
|---|
| 359 |
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); |
|---|
| 360 |
} |
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
public static function getOMClass() |
|---|
| 364 |
{ |
|---|
| 365 |
return CommentPeer::CLASS_DEFAULT; |
|---|
| 366 |
} |
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
public static function doInsert($values, $con = null) |
|---|
| 370 |
{ |
|---|
| 371 |
if ($con === null) { |
|---|
| 372 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 373 |
} |
|---|
| 374 |
|
|---|
| 375 |
if ($values instanceof Criteria) { |
|---|
| 376 |
$criteria = clone $values; } else { |
|---|
| 377 |
$criteria = $values->buildCriteria(); } |
|---|
| 378 |
|
|---|
| 379 |
$criteria->remove(CommentPeer::ID); |
|---|
| 380 |
|
|---|
| 381 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 382 |
|
|---|
| 383 |
try { |
|---|
| 384 |
$con->begin(); |
|---|
| 385 |
$pk = BasePeer::doInsert($criteria, $con); |
|---|
| 386 |
$con->commit(); |
|---|
| 387 |
} catch(PropelException $e) { |
|---|
| 388 |
$con->rollback(); |
|---|
| 389 |
throw $e; |
|---|
| 390 |
} |
|---|
| 391 |
|
|---|
| 392 |
return $pk; |
|---|
| 393 |
} |
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 |
public static function doUpdate($values, $con = null) |
|---|
| 397 |
{ |
|---|
| 398 |
if ($con === null) { |
|---|
| 399 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 400 |
} |
|---|
| 401 |
|
|---|
| 402 |
$selectCriteria = new Criteria(self::DATABASE_NAME); |
|---|
| 403 |
|
|---|
| 404 |
if ($values instanceof Criteria) { |
|---|
| 405 |
$criteria = clone $values; |
|---|
| 406 |
$comparison = $criteria->getComparison(CommentPeer::ID); |
|---|
| 407 |
$selectCriteria->add(CommentPeer::ID, $criteria->remove(CommentPeer::ID), $comparison); |
|---|
| 408 |
|
|---|
| 409 |
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } |
|---|
| 410 |
|
|---|
| 411 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 412 |
|
|---|
| 413 |
return BasePeer::doUpdate($selectCriteria, $criteria, $con); |
|---|
| 414 |
} |
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
public static function doDeleteAll($con = null) |
|---|
| 418 |
{ |
|---|
| 419 |
if ($con === null) { |
|---|
| 420 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 421 |
} |
|---|
| 422 |
$affectedRows = 0; try { |
|---|
| 423 |
$con->begin(); |
|---|
| 424 |
$affectedRows += BasePeer::doDeleteAll(CommentPeer::TABLE_NAME, $con); |
|---|
| 425 |
$con->commit(); |
|---|
| 426 |
return $affectedRows; |
|---|
| 427 |
} catch (PropelException $e) { |
|---|
| 428 |
$con->rollback(); |
|---|
| 429 |
throw $e; |
|---|
| 430 |
} |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
public static function doDelete($values, $con = null) |
|---|
| 435 |
{ |
|---|
| 436 |
if ($con === null) { |
|---|
| 437 |
$con = Propel::getConnection(CommentPeer::DATABASE_NAME); |
|---|
| 438 |
} |
|---|
| 439 |
|
|---|
| 440 |
if ($values instanceof Criteria) { |
|---|
| 441 |
$criteria = clone $values; } elseif ($values instanceof Comment) { |
|---|
| 442 |
|
|---|
| 443 |
$criteria = $values->buildPkeyCriteria(); |
|---|
| 444 |
} else { |
|---|
| 445 |
$criteria = new Criteria(self::DATABASE_NAME); |
|---|
| 446 |
$criteria->add(CommentPeer::ID, (array) $values, Criteria::IN); |
|---|
| 447 |
} |
|---|
| 448 |
|
|---|
| 449 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 450 |
|
|---|
| 451 |
$affectedRows = 0; |
|---|
| 452 |
try { |
|---|
| 453 |
$con->begin(); |
|---|
| 454 |
|
|---|
| 455 |
$affectedRows += BasePeer::doDelete($criteria, $con); |
|---|
| 456 |
$con->commit(); |
|---|
| 457 |
return $affectedRows; |
|---|
| 458 |
} catch (PropelException $e) { |
|---|
| 459 |
$con->rollback(); |
|---|
| 460 |
throw $e; |
|---|
| 461 |
} |
|---|
| 462 |
} |
|---|
| 463 |
|
|---|
| 464 |
|
|---|
| 465 |
public static function doValidate(Comment $obj, $cols = null) |
|---|
| 466 |
{ |
|---|
| 467 |
$columns = array(); |
|---|
| 468 |
|
|---|
| 469 |
if ($cols) { |
|---|
| 470 |
$dbMap = Propel::getDatabaseMap(CommentPeer::DATABASE_NAME); |
|---|
| 471 |
$tableMap = $dbMap->getTable(CommentPeer::TABLE_NAME); |
|---|
| 472 |
|
|---|
| 473 |
if (! is_array($cols)) { |
|---|
| 474 |
$cols = array($cols); |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
foreach($cols as $colName) { |
|---|
| 478 |
if ($tableMap->containsColumn($colName)) { |
|---|
| 479 |
$get = 'get' . $tableMap->getColumn($colName)->getPhpName(); |
|---|
| 480 |
$columns[$colName] = $obj->$get(); |
|---|
| 481 |
} |
|---|
| 482 |
} |
|---|
| 483 |
} else { |
|---|
| 484 |
|
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
$res = BasePeer::doValidate(CommentPeer::DATABASE_NAME, CommentPeer::TABLE_NAME, $columns); |
|---|
| 488 |
if ($res !== true) { |
|---|
| 489 |
$request = sfContext::getInstance()->getRequest(); |
|---|
| 490 |
foreach ($res as $failed) { |
|---|
| 491 |
$col = CommentPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); |
|---|
| 492 |
$request->setError($col, $failed->getMessage()); |
|---|
| 493 |
} |
|---|
| 494 |
} |
|---|
| 495 |
|
|---|
| 496 |
return $res; |
|---|
| 497 |
} |
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
public static function retrieveByPK($pk, $con = null) |
|---|
| 501 |
{ |
|---|
| 502 |
if ($con === null) { |
|---|
| 503 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 504 |
} |
|---|
| 505 |
|
|---|
| 506 |
$criteria = new Criteria(CommentPeer::DATABASE_NAME); |
|---|
| 507 |
|
|---|
| 508 |
$criteria->add(CommentPeer::ID, $pk); |
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
$v = CommentPeer::doSelect($criteria, $con); |
|---|
| 512 |
|
|---|
| 513 |
return !empty($v) > 0 ? $v[0] : null; |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
public static function retrieveByPKs($pks, $con = null) |
|---|
| 518 |
{ |
|---|
| 519 |
if ($con === null) { |
|---|
| 520 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 521 |
} |
|---|
| 522 |
|
|---|
| 523 |
$objs = null; |
|---|
| 524 |
if (empty($pks)) { |
|---|
| 525 |
$objs = array(); |
|---|
| 526 |
} else { |
|---|
| 527 |
$criteria = new Criteria(); |
|---|
| 528 |
$criteria->add(CommentPeer::ID, $pks, Criteria::IN); |
|---|
| 529 |
$objs = CommentPeer::doSelect($criteria, $con); |
|---|
| 530 |
} |
|---|
| 531 |
return $objs; |
|---|
| 532 |
} |
|---|
| 533 |
|
|---|
| 534 |
} |
|---|
| 535 |
if (Propel::isInit()) { |
|---|
| 536 |
try { |
|---|
| 537 |
BaseCommentPeer::getMapBuilder(); |
|---|
| 538 |
} catch (Exception $e) { |
|---|
| 539 |
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); |
|---|
| 540 |
} |
|---|
| 541 |
} else { |
|---|
| 542 |
require_once 'lib/model/map/CommentMapBuilder.php'; |
|---|
| 543 |
Propel::registerMapBuilder('lib.model.map.CommentMapBuilder'); |
|---|
| 544 |
} |
|---|
| 545 |
|
|---|