| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
require_once 'propel/util/BasePeer.php'; |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
include_once 'model/Relevancy.php'; |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
abstract class BaseRelevancyPeer { |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
const DATABASE_NAME = 'symfony'; |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
const TABLE_NAME = 'ask_relevancy'; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
const CLASS_DEFAULT = 'model.Relevancy'; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
const NUM_COLUMNS = 4; |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
const NUM_LAZY_LOAD_COLUMNS = 0; |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
const ANSWER_ID = 'ask_relevancy.ANSWER_ID'; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
const USER_ID = 'ask_relevancy.USER_ID'; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
const SCORE = 'ask_relevancy.SCORE'; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
const CREATED_AT = 'ask_relevancy.CREATED_AT'; |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
private static $phpNameMap = null; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
* holds an array of fieldnames |
|---|
| 51 |
* |
|---|
| 52 |
* first dimension keys are the type constants |
|---|
| 53 |
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|---|
| 54 |
*/ |
|---|
| 55 |
private static $fieldNames = array ( |
|---|
| 56 |
BasePeer::TYPE_PHPNAME => array ('AnswerId', 'UserId', 'Score', 'CreatedAt', ), |
|---|
| 57 |
BasePeer::TYPE_COLNAME => array (RelevancyPeer::ANSWER_ID, RelevancyPeer::USER_ID, RelevancyPeer::SCORE, RelevancyPeer::CREATED_AT, ), |
|---|
| 58 |
BasePeer::TYPE_FIELDNAME => array ('answer_id', 'user_id', 'score', 'created_at', ), |
|---|
| 59 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) |
|---|
| 60 |
); |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
* holds an array of keys for quick access to the fieldnames array |
|---|
| 64 |
* |
|---|
| 65 |
* first dimension keys are the type constants |
|---|
| 66 |
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 |
|---|
| 67 |
*/ |
|---|
| 68 |
private static $fieldKeys = array ( |
|---|
| 69 |
BasePeer::TYPE_PHPNAME => array ('AnswerId' => 0, 'UserId' => 1, 'Score' => 2, 'CreatedAt' => 3, ), |
|---|
| 70 |
BasePeer::TYPE_COLNAME => array (RelevancyPeer::ANSWER_ID => 0, RelevancyPeer::USER_ID => 1, RelevancyPeer::SCORE => 2, RelevancyPeer::CREATED_AT => 3, ), |
|---|
| 71 |
BasePeer::TYPE_FIELDNAME => array ('answer_id' => 0, 'user_id' => 1, 'score' => 2, 'created_at' => 3, ), |
|---|
| 72 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) |
|---|
| 73 |
); |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
* @return MapBuilder the map builder for this peer |
|---|
| 77 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 78 |
* rethrown wrapped into a PropelException. |
|---|
| 79 |
*/ |
|---|
| 80 |
public static function getMapBuilder() |
|---|
| 81 |
{ |
|---|
| 82 |
include_once 'model/map/RelevancyMapBuilder.php'; |
|---|
| 83 |
return BasePeer::getMapBuilder('model.map.RelevancyMapBuilder'); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
* Gets a map (hash) of PHP names to DB column names. |
|---|
| 87 |
* |
|---|
| 88 |
* @return array The PHP to DB name map for this peer |
|---|
| 89 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 90 |
* rethrown wrapped into a PropelException. |
|---|
| 91 |
* @todo Consider having template build the array rather than doing it at runtime. |
|---|
| 92 |
*/ |
|---|
| 93 |
public static function getPhpNameMap() |
|---|
| 94 |
{ |
|---|
| 95 |
if (self::$phpNameMap === null) { |
|---|
| 96 |
$map = RelevancyPeer::getTableMap(); |
|---|
| 97 |
$columns = $map->getColumns(); |
|---|
| 98 |
$nameMap = array(); |
|---|
| 99 |
foreach ($columns as $column) { |
|---|
| 100 |
$nameMap[$column->getPhpName()] = $column->getColumnName(); |
|---|
| 101 |
} |
|---|
| 102 |
self::$phpNameMap = $nameMap; |
|---|
| 103 |
} |
|---|
| 104 |
return self::$phpNameMap; |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
* Translates a fieldname to another type |
|---|
| 108 |
* |
|---|
| 109 |
* @param string $name field name |
|---|
| 110 |
* @param string $fromType One of the class type constants TYPE_PHPNAME, |
|---|
| 111 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 112 |
* @param string $toType One of the class type constants |
|---|
| 113 |
* @return string translated name of the field. |
|---|
| 114 |
*/ |
|---|
| 115 |
static public function translateFieldName($name, $fromType, $toType) |
|---|
| 116 |
{ |
|---|
| 117 |
$toNames = self::getFieldNames($toType); |
|---|
| 118 |
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; |
|---|
| 119 |
if ($key === null) { |
|---|
| 120 |
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); |
|---|
| 121 |
} |
|---|
| 122 |
return $toNames[$key]; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
* Returns an array of of field names. |
|---|
| 127 |
* |
|---|
| 128 |
* @param string $type The type of fieldnames to return: |
|---|
| 129 |
* One of the class type constants TYPE_PHPNAME, |
|---|
| 130 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 131 |
* @return array A list of field names |
|---|
| 132 |
*/ |
|---|
| 133 |
|
|---|
| 134 |
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) |
|---|
| 135 |
{ |
|---|
| 136 |
if (!array_key_exists($type, self::$fieldNames)) { |
|---|
| 137 |
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.'); |
|---|
| 138 |
} |
|---|
| 139 |
return self::$fieldNames[$type]; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
* Convenience method which changes table.column to alias.column. |
|---|
| 144 |
* |
|---|
| 145 |
* Using this method you can maintain SQL abstraction while using column aliases. |
|---|
| 146 |
* <code> |
|---|
| 147 |
* $c->addAlias("alias1", TablePeer::TABLE_NAME); |
|---|
| 148 |
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); |
|---|
| 149 |
* </code> |
|---|
| 150 |
* @param string $alias The alias for the current table. |
|---|
| 151 |
* @param string $column The column name for current table. (i.e. RelevancyPeer::COLUMN_NAME). |
|---|
| 152 |
* @return string |
|---|
| 153 |
*/ |
|---|
| 154 |
public static function alias($alias, $column) |
|---|
| 155 |
{ |
|---|
| 156 |
return $alias . substr($column, strlen(RelevancyPeer::TABLE_NAME)); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
* Add all the columns needed to create a new object. |
|---|
| 161 |
* |
|---|
| 162 |
* Note: any columns that were marked with lazyLoad="true" in the |
|---|
| 163 |
* XML schema will not be added to the select list and only loaded |
|---|
| 164 |
* on demand. |
|---|
| 165 |
* |
|---|
| 166 |
* @param criteria object containing the columns to add. |
|---|
| 167 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 168 |
* rethrown wrapped into a PropelException. |
|---|
| 169 |
*/ |
|---|
| 170 |
public static function addSelectColumns(Criteria $criteria) |
|---|
| 171 |
{ |
|---|
| 172 |
|
|---|
| 173 |
$criteria->addSelectColumn(RelevancyPeer::ANSWER_ID); |
|---|
| 174 |
|
|---|
| 175 |
$criteria->addSelectColumn(RelevancyPeer::USER_ID); |
|---|
| 176 |
|
|---|
| 177 |
$criteria->addSelectColumn(RelevancyPeer::SCORE); |
|---|
| 178 |
|
|---|
| 179 |
$criteria->addSelectColumn(RelevancyPeer::CREATED_AT); |
|---|
| 180 |
|
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
const COUNT = 'COUNT(*)'; |
|---|
| 184 |
const COUNT_DISTINCT = 'COUNT(DISTINCT *)'; |
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
* Returns the number of rows matching criteria. |
|---|
| 188 |
* |
|---|
| 189 |
* @param Criteria $criteria |
|---|
| 190 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 191 |
* @param Connection $con |
|---|
| 192 |
* @return int Number of matching rows. |
|---|
| 193 |
*/ |
|---|
| 194 |
public static function doCount(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 195 |
{ |
|---|
| 196 |
|
|---|
| 197 |
$criteria = clone $criteria; |
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 201 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 202 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 203 |
} else { |
|---|
| 204 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 209 |
{ |
|---|
| 210 |
$criteria->addSelectColumn($column); |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 214 |
if ($rs->next()) { |
|---|
| 215 |
return $rs->getInt(1); |
|---|
| 216 |
} else { |
|---|
| 217 |
|
|---|
| 218 |
return 0; |
|---|
| 219 |
} |
|---|
| 220 |
} |
|---|
| 221 |
|
|---|
| 222 |
* Method to select one object from the DB. |
|---|
| 223 |
* |
|---|
| 224 |
* @param Criteria $criteria object used to create the SELECT statement. |
|---|
| 225 |
* @param Connection $con |
|---|
| 226 |
* @return Relevancy |
|---|
| 227 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 228 |
* rethrown wrapped into a PropelException. |
|---|
| 229 |
*/ |
|---|
| 230 |
public static function doSelectOne(Criteria $criteria, $con = null) |
|---|
| 231 |
{ |
|---|
| 232 |
$critcopy = clone $criteria; |
|---|
| 233 |
$critcopy->setLimit(1); |
|---|
| 234 |
$objects = RelevancyPeer::doSelect($critcopy, $con); |
|---|
| 235 |
if ($objects) { |
|---|
| 236 |
return $objects[0]; |
|---|
| 237 |
} |
|---|
| 238 |
return null; |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
* Method to do selects. |
|---|
| 242 |
* |
|---|
| 243 |
* @param Criteria $criteria The Criteria object used to build the SELECT statement. |
|---|
| 244 |
* @param Connection $con |
|---|
| 245 |
* @return array Array of selected Objects |
|---|
| 246 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 247 |
* rethrown wrapped into a PropelException. |
|---|
| 248 |
*/ |
|---|
| 249 |
public static function doSelect(Criteria $criteria, $con = null) |
|---|
| 250 |
{ |
|---|
| 251 |
return RelevancyPeer::populateObjects(RelevancyPeer::doSelectRS($criteria, $con)); |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
* Prepares the Criteria object and uses the parent doSelect() |
|---|
| 255 |
* method to get a ResultSet. |
|---|
| 256 |
* |
|---|
| 257 |
* Use this method directly if you want to just get the resultset |
|---|
| 258 |
* (instead of an array of objects). |
|---|
| 259 |
* |
|---|
| 260 |
* @param Criteria $criteria The Criteria object used to build the SELECT statement. |
|---|
| 261 |
* @param Connection $con the connection to use |
|---|
| 262 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 263 |
* rethrown wrapped into a PropelException. |
|---|
| 264 |
* @return ResultSet The resultset object with numerically-indexed fields. |
|---|
| 265 |
* @see BasePeer::doSelect() |
|---|
| 266 |
*/ |
|---|
| 267 |
public static function doSelectRS(Criteria $criteria, $con = null) |
|---|
| 268 |
{ |
|---|
| 269 |
if ($con === null) { |
|---|
| 270 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
if (!$criteria->getSelectColumns()) { |
|---|
| 274 |
$criteria = clone $criteria; |
|---|
| 275 |
RelevancyPeer::addSelectColumns($criteria); |
|---|
| 276 |
} |
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
// rows indexed numerically. |
|---|
| 283 |
return BasePeer::doSelect($criteria, $con); |
|---|
| 284 |
} |
|---|
| 285 |
|
|---|
| 286 |
* The returned array will contain objects of the default type or |
|---|
| 287 |
* objects that inherit from the default. |
|---|
| 288 |
* |
|---|
| 289 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 290 |
* rethrown wrapped into a PropelException. |
|---|
| 291 |
*/ |
|---|
| 292 |
public static function populateObjects(ResultSet $rs) |
|---|
| 293 |
{ |
|---|
| 294 |
$results = array(); |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
$cls = RelevancyPeer::getOMClass(); |
|---|
| 298 |
$cls = Propel::import($cls); |
|---|
| 299 |
|
|---|
| 300 |
while($rs->next()) { |
|---|
| 301 |
|
|---|
| 302 |
$obj = new $cls(); |
|---|
| 303 |
$obj->hydrate($rs); |
|---|
| 304 |
$results[] = $obj; |
|---|
| 305 |
|
|---|
| 306 |
} |
|---|
| 307 |
return $results; |
|---|
| 308 |
} |
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
* Returns the number of rows matching criteria, joining the related Answer table |
|---|
| 312 |
* |
|---|
| 313 |
* @param Criteria $c |
|---|
| 314 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 315 |
* @param Connection $con |
|---|
| 316 |
* @return int Number of matching rows. |
|---|
| 317 |
*/ |
|---|
| 318 |
public static function doCountJoinAnswer(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 319 |
{ |
|---|
| 320 |
|
|---|
| 321 |
$criteria = clone $criteria; |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 325 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 326 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 327 |
} else { |
|---|
| 328 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 329 |
} |
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 333 |
{ |
|---|
| 334 |
$criteria->addSelectColumn($column); |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
$criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 338 |
|
|---|
| 339 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 340 |
if ($rs->next()) { |
|---|
| 341 |
return $rs->getInt(1); |
|---|
| 342 |
} else { |
|---|
| 343 |
|
|---|
| 344 |
return 0; |
|---|
| 345 |
} |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 |
* Returns the number of rows matching criteria, joining the related User table |
|---|
| 351 |
* |
|---|
| 352 |
* @param Criteria $c |
|---|
| 353 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 354 |
* @param Connection $con |
|---|
| 355 |
* @return int Number of matching rows. |
|---|
| 356 |
*/ |
|---|
| 357 |
public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 358 |
{ |
|---|
| 359 |
|
|---|
| 360 |
$criteria = clone $criteria; |
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 364 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 365 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 366 |
} else { |
|---|
| 367 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 372 |
{ |
|---|
| 373 |
$criteria->addSelectColumn($column); |
|---|
| 374 |
} |
|---|
| 375 |
|
|---|
| 376 |
$criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 377 |
|
|---|
| 378 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 379 |
if ($rs->next()) { |
|---|
| 380 |
return $rs->getInt(1); |
|---|
| 381 |
} else { |
|---|
| 382 |
|
|---|
| 383 |
return 0; |
|---|
| 384 |
} |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
* Selects a collection of Relevancy objects pre-filled with their Answer objects. |
|---|
| 390 |
* |
|---|
| 391 |
* @return array Array of Relevancy objects. |
|---|
| 392 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 393 |
* rethrown wrapped into a PropelException. |
|---|
| 394 |
*/ |
|---|
| 395 |
public static function doSelectJoinAnswer(Criteria $c, $con = null) |
|---|
| 396 |
{ |
|---|
| 397 |
$c = clone $c; |
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 401 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 402 |
} |
|---|
| 403 |
|
|---|
| 404 |
RelevancyPeer::addSelectColumns($c); |
|---|
| 405 |
$startcol = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 406 |
AnswerPeer::addSelectColumns($c); |
|---|
| 407 |
|
|---|
| 408 |
$c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 409 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 410 |
$results = array(); |
|---|
| 411 |
|
|---|
| 412 |
while($rs->next()) { |
|---|
| 413 |
|
|---|
| 414 |
$omClass = RelevancyPeer::getOMClass(); |
|---|
| 415 |
|
|---|
| 416 |
$cls = Propel::import($omClass); |
|---|
| 417 |
$obj1 = new $cls(); |
|---|
| 418 |
$obj1->hydrate($rs); |
|---|
| 419 |
|
|---|
| 420 |
$omClass = AnswerPeer::getOMClass(); |
|---|
| 421 |
|
|---|
| 422 |
$cls = Propel::import($omClass); |
|---|
| 423 |
$obj2 = new $cls(); |
|---|
| 424 |
$obj2->hydrate($rs, $startcol); |
|---|
| 425 |
|
|---|
| 426 |
$newObject = true; |
|---|
| 427 |
foreach($results as $temp_obj1) { |
|---|
| 428 |
$temp_obj2 = $temp_obj1->getAnswer(); |
|---|
| 429 |
if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 430 |
$newObject = false; |
|---|
| 431 |
|
|---|
| 432 |
$temp_obj2->addRelevancy($obj1); |
|---|
| 433 |
break; |
|---|
| 434 |
} |
|---|
| 435 |
} |
|---|
| 436 |
if ($newObject) { |
|---|
| 437 |
$obj2->initRelevancys(); |
|---|
| 438 |
$obj2->addRelevancy($obj1); |
|---|
| 439 |
} |
|---|
| 440 |
$results[] = $obj1; |
|---|
| 441 |
} |
|---|
| 442 |
return $results; |
|---|
| 443 |
} |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
* Selects a collection of Relevancy objects pre-filled with their User objects. |
|---|
| 448 |
* |
|---|
| 449 |
* @return array Array of Relevancy objects. |
|---|
| 450 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 451 |
* rethrown wrapped into a PropelException. |
|---|
| 452 |
*/ |
|---|
| 453 |
public static function doSelectJoinUser(Criteria $c, $con = null) |
|---|
| 454 |
{ |
|---|
| 455 |
$c = clone $c; |
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 459 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 460 |
} |
|---|
| 461 |
|
|---|
| 462 |
RelevancyPeer::addSelectColumns($c); |
|---|
| 463 |
$startcol = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 464 |
UserPeer::addSelectColumns($c); |
|---|
| 465 |
|
|---|
| 466 |
$c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 467 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 468 |
$results = array(); |
|---|
| 469 |
|
|---|
| 470 |
while($rs->next()) { |
|---|
| 471 |
|
|---|
| 472 |
$omClass = RelevancyPeer::getOMClass(); |
|---|
| 473 |
|
|---|
| 474 |
$cls = Propel::import($omClass); |
|---|
| 475 |
$obj1 = new $cls(); |
|---|
| 476 |
$obj1->hydrate($rs); |
|---|
| 477 |
|
|---|
| 478 |
$omClass = UserPeer::getOMClass(); |
|---|
| 479 |
|
|---|
| 480 |
$cls = Propel::import($omClass); |
|---|
| 481 |
$obj2 = new $cls(); |
|---|
| 482 |
$obj2->hydrate($rs, $startcol); |
|---|
| 483 |
|
|---|
| 484 |
$newObject = true; |
|---|
| 485 |
foreach($results as $temp_obj1) { |
|---|
| 486 |
$temp_obj2 = $temp_obj1->getUser(); |
|---|
| 487 |
if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 488 |
$newObject = false; |
|---|
| 489 |
|
|---|
| 490 |
$temp_obj2->addRelevancy($obj1); |
|---|
| 491 |
break; |
|---|
| 492 |
} |
|---|
| 493 |
} |
|---|
| 494 |
if ($newObject) { |
|---|
| 495 |
$obj2->initRelevancys(); |
|---|
| 496 |
$obj2->addRelevancy($obj1); |
|---|
| 497 |
} |
|---|
| 498 |
$results[] = $obj1; |
|---|
| 499 |
} |
|---|
| 500 |
return $results; |
|---|
| 501 |
} |
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
* Returns the number of rows matching criteria, joining all related tables |
|---|
| 506 |
* |
|---|
| 507 |
* @param Criteria $c |
|---|
| 508 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 509 |
* @param Connection $con |
|---|
| 510 |
* @return int Number of matching rows. |
|---|
| 511 |
*/ |
|---|
| 512 |
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 513 |
{ |
|---|
| 514 |
$criteria = clone $criteria; |
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 518 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 519 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 520 |
} else { |
|---|
| 521 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 522 |
} |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 526 |
{ |
|---|
| 527 |
$criteria->addSelectColumn($column); |
|---|
| 528 |
} |
|---|
| 529 |
|
|---|
| 530 |
$criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 531 |
|
|---|
| 532 |
$criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 533 |
|
|---|
| 534 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 535 |
if ($rs->next()) { |
|---|
| 536 |
return $rs->getInt(1); |
|---|
| 537 |
} else { |
|---|
| 538 |
|
|---|
| 539 |
return 0; |
|---|
| 540 |
} |
|---|
| 541 |
} |
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
* Selects a collection of Relevancy objects pre-filled with all related objects. |
|---|
| 546 |
* |
|---|
| 547 |
* @return array Array of Relevancy objects. |
|---|
| 548 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 549 |
* rethrown wrapped into a PropelException. |
|---|
| 550 |
*/ |
|---|
| 551 |
public static function doSelectJoinAll(Criteria $c, $con = null) |
|---|
| 552 |
{ |
|---|
| 553 |
$c = clone $c; |
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 557 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
RelevancyPeer::addSelectColumns($c); |
|---|
| 561 |
$startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 562 |
|
|---|
| 563 |
AnswerPeer::addSelectColumns($c); |
|---|
| 564 |
$startcol3 = $startcol2 + AnswerPeer::NUM_COLUMNS; |
|---|
| 565 |
|
|---|
| 566 |
UserPeer::addSelectColumns($c); |
|---|
| 567 |
$startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; |
|---|
| 568 |
|
|---|
| 569 |
$c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 570 |
|
|---|
| 571 |
$c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 572 |
|
|---|
| 573 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 574 |
$results = array(); |
|---|
| 575 |
|
|---|
| 576 |
while($rs->next()) { |
|---|
| 577 |
|
|---|
| 578 |
$omClass = RelevancyPeer::getOMClass(); |
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
$cls = Propel::import($omClass); |
|---|
| 582 |
$obj1 = new $cls(); |
|---|
| 583 |
$obj1->hydrate($rs); |
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
|
|---|
| 588 |
$omClass = AnswerPeer::getOMClass(); |
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
$cls = Propel::import($omClass); |
|---|
| 592 |
$obj2 = new $cls(); |
|---|
| 593 |
$obj2->hydrate($rs, $startcol2); |
|---|
| 594 |
|
|---|
| 595 |
$newObject = true; |
|---|
| 596 |
for ($j=0, $resCount=count($results); $j < $resCount; $j++) { |
|---|
| 597 |
$temp_obj1 = $results[$j]; |
|---|
| 598 |
$temp_obj2 = $temp_obj1->getAnswer(); |
|---|
| 599 |
if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 600 |
$newObject = false; |
|---|
| 601 |
$temp_obj2->addRelevancy($obj1); |
|---|
| 602 |
break; |
|---|
| 603 |
} |
|---|
| 604 |
} |
|---|
| 605 |
|
|---|
| 606 |
if ($newObject) { |
|---|
| 607 |
$obj2->initRelevancys(); |
|---|
| 608 |
$obj2->addRelevancy($obj1); |
|---|
| 609 |
} |
|---|
| 610 |
|
|---|
| 611 |
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
$omClass = UserPeer::getOMClass(); |
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
$cls = Propel::import($omClass); |
|---|
| 618 |
$obj3 = new $cls(); |
|---|
| 619 |
$obj3->hydrate($rs, $startcol3); |
|---|
| 620 |
|
|---|
| 621 |
$newObject = true; |
|---|
| 622 |
for ($j=0, $resCount=count($results); $j < $resCount; $j++) { |
|---|
| 623 |
$temp_obj1 = $results[$j]; |
|---|
| 624 |
$temp_obj3 = $temp_obj1->getUser(); |
|---|
| 625 |
if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { |
|---|
| 626 |
$newObject = false; |
|---|
| 627 |
$temp_obj3->addRelevancy($obj1); |
|---|
| 628 |
break; |
|---|
| 629 |
} |
|---|
| 630 |
} |
|---|
| 631 |
|
|---|
| 632 |
if ($newObject) { |
|---|
| 633 |
$obj3->initRelevancys(); |
|---|
| 634 |
$obj3->addRelevancy($obj1); |
|---|
| 635 |
} |
|---|
| 636 |
|
|---|
| 637 |
$results[] = $obj1; |
|---|
| 638 |
} |
|---|
| 639 |
return $results; |
|---|
| 640 |
} |
|---|
| 641 |
|
|---|
| 642 |
|
|---|
| 643 |
|
|---|
| 644 |
* Returns the number of rows matching criteria, joining the related Answer table |
|---|
| 645 |
* |
|---|
| 646 |
* @param Criteria $c |
|---|
| 647 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 648 |
* @param Connection $con |
|---|
| 649 |
* @return int Number of matching rows. |
|---|
| 650 |
*/ |
|---|
| 651 |
public static function doCountJoinAllExceptAnswer(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 652 |
{ |
|---|
| 653 |
|
|---|
| 654 |
$criteria = clone $criteria; |
|---|
| 655 |
|
|---|
| 656 |
|
|---|
| 657 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 658 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 659 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 660 |
} else { |
|---|
| 661 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 662 |
} |
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 666 |
{ |
|---|
| 667 |
$criteria->addSelectColumn($column); |
|---|
| 668 |
} |
|---|
| 669 |
|
|---|
| 670 |
$criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 671 |
|
|---|
| 672 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 673 |
if ($rs->next()) { |
|---|
| 674 |
return $rs->getInt(1); |
|---|
| 675 |
} else { |
|---|
| 676 |
|
|---|
| 677 |
return 0; |
|---|
| 678 |
} |
|---|
| 679 |
} |
|---|
| 680 |
|
|---|
| 681 |
|
|---|
| 682 |
|
|---|
| 683 |
* Returns the number of rows matching criteria, joining the related User table |
|---|
| 684 |
* |
|---|
| 685 |
* @param Criteria $c |
|---|
| 686 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 687 |
* @param Connection $con |
|---|
| 688 |
* @return int Number of matching rows. |
|---|
| 689 |
*/ |
|---|
| 690 |
public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 691 |
{ |
|---|
| 692 |
|
|---|
| 693 |
$criteria = clone $criteria; |
|---|
| 694 |
|
|---|
| 695 |
|
|---|
| 696 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 697 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 698 |
$criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); |
|---|
| 699 |
} else { |
|---|
| 700 |
$criteria->addSelectColumn(RelevancyPeer::COUNT); |
|---|
| 701 |
} |
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 705 |
{ |
|---|
| 706 |
$criteria->addSelectColumn($column); |
|---|
| 707 |
} |
|---|
| 708 |
|
|---|
| 709 |
$criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 710 |
|
|---|
| 711 |
$rs = RelevancyPeer::doSelectRS($criteria, $con); |
|---|
| 712 |
if ($rs->next()) { |
|---|
| 713 |
return $rs->getInt(1); |
|---|
| 714 |
} else { |
|---|
| 715 |
|
|---|
| 716 |
return 0; |
|---|
| 717 |
} |
|---|
| 718 |
} |
|---|
| 719 |
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 |
* Selects a collection of Relevancy objects pre-filled with all related objects except Answer. |
|---|
| 723 |
* |
|---|
| 724 |
* @return array Array of Relevancy objects. |
|---|
| 725 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 726 |
* rethrown wrapped into a PropelException. |
|---|
| 727 |
*/ |
|---|
| 728 |
public static function doSelectJoinAllExceptAnswer(Criteria $c, $con = null) |
|---|
| 729 |
{ |
|---|
| 730 |
$c = clone $c; |
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
// $c->getDbName() will return the same object if not set to another value |
|---|
| 734 |
// so == check is okay and faster |
|---|
| 735 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 736 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 737 |
} |
|---|
| 738 |
|
|---|
| 739 |
RelevancyPeer::addSelectColumns($c); |
|---|
| 740 |
$startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 741 |
|
|---|
| 742 |
UserPeer::addSelectColumns($c); |
|---|
| 743 |
$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; |
|---|
| 744 |
|
|---|
| 745 |
$c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); |
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 749 |
$results = array(); |
|---|
| 750 |
|
|---|
| 751 |
while($rs->next()) { |
|---|
| 752 |
|
|---|
| 753 |
$omClass = RelevancyPeer::getOMClass(); |
|---|
| 754 |
|
|---|
| 755 |
$cls = Propel::import($omClass); |
|---|
| 756 |
$obj1 = new $cls(); |
|---|
| 757 |
$obj1->hydrate($rs); |
|---|
| 758 |
|
|---|
| 759 |
$omClass = UserPeer::getOMClass(); |
|---|
| 760 |
|
|---|
| 761 |
|
|---|
| 762 |
$cls = Propel::import($omClass); |
|---|
| 763 |
$obj2 = new $cls(); |
|---|
| 764 |
$obj2->hydrate($rs, $startcol2); |
|---|
| 765 |
|
|---|
| 766 |
$newObject = true; |
|---|
| 767 |
for ($j=0, $resCount=count($results); $j < $resCount; $j++) { |
|---|
| 768 |
$temp_obj1 = $results[$j]; |
|---|
| 769 |
$temp_obj2 = $temp_obj1->getUser(); |
|---|
| 770 |
if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 771 |
$newObject = false; |
|---|
| 772 |
$temp_obj2->addRelevancy($obj1); |
|---|
| 773 |
break; |
|---|
| 774 |
} |
|---|
| 775 |
} |
|---|
| 776 |
|
|---|
| 777 |
if ($newObject) { |
|---|
| 778 |
$obj2->initRelevancys(); |
|---|
| 779 |
$obj2->addRelevancy($obj1); |
|---|
| 780 |
} |
|---|
| 781 |
|
|---|
| 782 |
$results[] = $obj1; |
|---|
| 783 |
} |
|---|
| 784 |
return $results; |
|---|
| 785 |
} |
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 |
|
|---|
| 789 |
* Selects a collection of Relevancy objects pre-filled with all related objects except User. |
|---|
| 790 |
* |
|---|
| 791 |
* @return array Array of Relevancy objects. |
|---|
| 792 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 793 |
* rethrown wrapped into a PropelException. |
|---|
| 794 |
*/ |
|---|
| 795 |
public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) |
|---|
| 796 |
{ |
|---|
| 797 |
$c = clone $c; |
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 |
// $c->getDbName() will return the same object if not set to another value |
|---|
| 801 |
// so == check is okay and faster |
|---|
| 802 |
if ($c->getDbName() == Propel::getDefaultDB()) { |
|---|
| 803 |
$c->setDbName(self::DATABASE_NAME); |
|---|
| 804 |
} |
|---|
| 805 |
|
|---|
| 806 |
RelevancyPeer::addSelectColumns($c); |
|---|
| 807 |
$startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; |
|---|
| 808 |
|
|---|
| 809 |
AnswerPeer::addSelectColumns($c); |
|---|
| 810 |
$startcol3 = $startcol2 + AnswerPeer::NUM_COLUMNS; |
|---|
| 811 |
|
|---|
| 812 |
$c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); |
|---|
| 813 |
|
|---|
| 814 |
|
|---|
| 815 |
$rs = BasePeer::doSelect($c, $con); |
|---|
| 816 |
$results = array(); |
|---|
| 817 |
|
|---|
| 818 |
while($rs->next()) { |
|---|
| 819 |
|
|---|
| 820 |
$omClass = RelevancyPeer::getOMClass(); |
|---|
| 821 |
|
|---|
| 822 |
$cls = Propel::import($omClass); |
|---|
| 823 |
$obj1 = new $cls(); |
|---|
| 824 |
$obj1->hydrate($rs); |
|---|
| 825 |
|
|---|
| 826 |
$omClass = AnswerPeer::getOMClass(); |
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
$cls = Propel::import($omClass); |
|---|
| 830 |
$obj2 = new $cls(); |
|---|
| 831 |
$obj2->hydrate($rs, $startcol2); |
|---|
| 832 |
|
|---|
| 833 |
$newObject = true; |
|---|
| 834 |
for ($j=0, $resCount=count($results); $j < $resCount; $j++) { |
|---|
| 835 |
$temp_obj1 = $results[$j]; |
|---|
| 836 |
$temp_obj2 = $temp_obj1->getAnswer(); |
|---|
| 837 |
if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { |
|---|
| 838 |
$newObject = false; |
|---|
| 839 |
$temp_obj2->addRelevancy($obj1); |
|---|
| 840 |
break; |
|---|
| 841 |
} |
|---|
| 842 |
} |
|---|
| 843 |
|
|---|
| 844 |
if ($newObject) { |
|---|
| 845 |
$obj2->initRelevancys(); |
|---|
| 846 |
$obj2->addRelevancy($obj1); |
|---|
| 847 |
} |
|---|
| 848 |
|
|---|
| 849 |
$results[] = $obj1; |
|---|
| 850 |
} |
|---|
| 851 |
return $results; |
|---|
| 852 |
} |
|---|
| 853 |
|
|---|
| 854 |
|
|---|
| 855 |
* Returns the TableMap related to this peer. |
|---|
| 856 |
* This method is not needed for general use but a specific application could have a need. |
|---|
| 857 |
* @return TableMap |
|---|
| 858 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 859 |
* rethrown wrapped into a PropelException. |
|---|
| 860 |
*/ |
|---|
| 861 |
public static function getTableMap() |
|---|
| 862 |
{ |
|---|
| 863 |
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); |
|---|
| 864 |
} |
|---|
| 865 |
|
|---|
| 866 |
|
|---|
| 867 |
* The class that the Peer will make instances of. |
|---|
| 868 |
* |
|---|
| 869 |
* This uses a dot-path notation which is tranalted into a path |
|---|
| 870 |
* relative to a location on the PHP include_path. |
|---|
| 871 |
* (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|---|
| 872 |
* |
|---|
| 873 |
* @return string path.to.ClassName |
|---|
| 874 |
*/ |
|---|
| 875 |
public static function getOMClass() |
|---|
| 876 |
{ |
|---|
| 877 |
return RelevancyPeer::CLASS_DEFAULT; |
|---|
| 878 |
} |
|---|
| 879 |
|
|---|
| 880 |
|
|---|
| 881 |
* Method perform an INSERT on the database, given a Relevancy or Criteria object. |
|---|
| 882 |
* |
|---|
| 883 |
* @param mixed $values Criteria or Relevancy object containing data that is used to create the INSERT statement. |
|---|
| 884 |
* @param Connection $con the connection to use |
|---|
| 885 |
* @return mixed The new primary key. |
|---|
| 886 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 887 |
* rethrown wrapped into a PropelException. |
|---|
| 888 |
*/ |
|---|
| 889 |
public static function doInsert($values, $con = null) |
|---|
| 890 |
{ |
|---|
| 891 |
if ($con === null) { |
|---|
| 892 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 893 |
} |
|---|
| 894 |
|
|---|
| 895 |
if ($values instanceof Criteria) { |
|---|
| 896 |
$criteria = clone $values; |
|---|
| 897 |
} else { |
|---|
| 898 |
$criteria = $values->buildCriteria(); |
|---|
| 899 |
} |
|---|
| 900 |
|
|---|
| 901 |
|
|---|
| 902 |
|
|---|
| 903 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 904 |
|
|---|
| 905 |
try { |
|---|
| 906 |
|
|---|
| 907 |
// for more than one table (I guess, conceivably) |
|---|
| 908 |
$con->begin(); |
|---|
| 909 |
$pk = BasePeer::doInsert($criteria, $con); |
|---|
| 910 |
$con->commit(); |
|---|
| 911 |
} catch(PropelException $e) { |
|---|
| 912 |
$con->rollback(); |
|---|
| 913 |
throw $e; |
|---|
| 914 |
} |
|---|
| 915 |
|
|---|
| 916 |
return $pk; |
|---|
| 917 |
} |
|---|
| 918 |
|
|---|
| 919 |
|
|---|
| 920 |
* Method perform an UPDATE on the database, given a Relevancy or Criteria object. |
|---|
| 921 |
* |
|---|
| 922 |
* @param mixed $values Criteria or Relevancy object containing data that is used to create the UPDATE statement. |
|---|
| 923 |
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions). |
|---|
| 924 |
* @return int The number of affected rows (if supported by underlying database driver). |
|---|
| 925 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 926 |
* rethrown wrapped into a PropelException. |
|---|
| 927 |
*/ |
|---|
| 928 |
public static function doUpdate($values, $con = null) |
|---|
| 929 |
{ |
|---|
| 930 |
if ($con === null) { |
|---|
| 931 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 932 |
} |
|---|
| 933 |
|
|---|
| 934 |
$selectCriteria = new Criteria(self::DATABASE_NAME); |
|---|
| 935 |
|
|---|
| 936 |
if ($values instanceof Criteria) { |
|---|
| 937 |
$criteria = clone $values; |
|---|
| 938 |
|
|---|
| 939 |
} else { |
|---|
| 940 |
$criteria = $values->buildCriteria(); |
|---|
| 941 |
$selectCriteria = $values->buildPkeyCriteria(); |
|---|
| 942 |
} |
|---|
| 943 |
|
|---|
| 944 |
|
|---|
| 945 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 946 |
|
|---|
| 947 |
return BasePeer::doUpdate($selectCriteria, $criteria, $con); |
|---|
| 948 |
} |
|---|
| 949 |
|
|---|
| 950 |
|
|---|
| 951 |
* Method to DELETE all rows from the ask_relevancy table. |
|---|
| 952 |
* |
|---|
| 953 |
* @return int The number of affected rows (if supported by underlying database driver). |
|---|
| 954 |
*/ |
|---|
| 955 |
public static function doDeleteAll($con = null) |
|---|
| 956 |
{ |
|---|
| 957 |
if ($con === null) { |
|---|
| 958 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 959 |
} |
|---|
| 960 |
$affectedRows = 0; |
|---|
| 961 |
try { |
|---|
| 962 |
|
|---|
| 963 |
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
|---|
| 964 |
$con->begin(); |
|---|
| 965 |
$affectedRows += BasePeer::doDeleteAll(RelevancyPeer::TABLE_NAME, $con); |
|---|
| 966 |
$con->commit(); |
|---|
| 967 |
return $affectedRows; |
|---|
| 968 |
} catch (PropelException $e) { |
|---|
| 969 |
$con->rollback(); |
|---|
| 970 |
throw $e; |
|---|
| 971 |
} |
|---|
| 972 |
} |
|---|
| 973 |
|
|---|
| 974 |
|
|---|
| 975 |
* Method perform a DELETE on the database, given a Relevancy or Criteria object OR a primary key value. |
|---|
| 976 |
* |
|---|
| 977 |
* @param mixed $values Criteria or Relevancy object or primary key or array of primary keys |
|---|
| 978 |
* which is used to create the DELETE statement |
|---|
| 979 |
* @param Connection $con the connection to use |
|---|
| 980 |
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|---|
| 981 |
* if supported by native driver or if emulated using Propel. |
|---|
| 982 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 983 |
* rethrown wrapped into a PropelException. |
|---|
| 984 |
*/ |
|---|
| 985 |
public static function doDelete($values, $con = null) |
|---|
| 986 |
{ |
|---|
| 987 |
if ($con === null) { |
|---|
| 988 |
$con = Propel::getConnection(RelevancyPeer::DATABASE_NAME); |
|---|
| 989 |
} |
|---|
| 990 |
|
|---|
| 991 |
if ($values instanceof Criteria) { |
|---|
| 992 |
$criteria = clone $values; |
|---|
| 993 |
} elseif ($values instanceof Relevancy) { |
|---|
| 994 |
|
|---|
| 995 |
$criteria = $values->buildCriteria(); |
|---|
| 996 |
} else { |
|---|
| 997 |
|
|---|
| 998 |
$criteria = new Criteria(self::DATABASE_NAME); |
|---|
| 999 |
|
|---|
| 1000 |
// the primary key passed to be an array of pkey |
|---|
| 1001 |
// values |
|---|
| 1002 |
if(count($values) == count($values, COUNT_RECURSIVE)) |
|---|
| 1003 |
{ |
|---|
| 1004 |
|
|---|
| 1005 |
$values = array($values); |
|---|
| 1006 |
} |
|---|
| 1007 |
$vals = array(); |
|---|
| 1008 |
foreach($values as $value) |
|---|
| 1009 |
{ |
|---|
| 1010 |
|
|---|
| 1011 |
} |
|---|
| 1012 |
|
|---|
| 1013 |
} |
|---|
| 1014 |
|
|---|
| 1015 |
|
|---|
| 1016 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 1017 |
|
|---|
| 1018 |
$affectedRows = 0; |
|---|
| 1019 |
|
|---|
| 1020 |
try { |
|---|
| 1021 |
|
|---|
| 1022 |
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
|---|
| 1023 |
$con->begin(); |
|---|
| 1024 |
|
|---|
| 1025 |
$affectedRows += BasePeer::doDelete($criteria, $con); |
|---|
| 1026 |
$con->commit(); |
|---|
| 1027 |
return $affectedRows; |
|---|
| 1028 |
} catch (PropelException $e) { |
|---|
| 1029 |
$con->rollback(); |
|---|
| 1030 |
throw $e; |
|---|
| 1031 |
} |
|---|
| 1032 |
} |
|---|
| 1033 |
|
|---|
| 1034 |
|
|---|
| 1035 |
* Validates all modified columns of given Relevancy object. |
|---|
| 1036 |
* If parameter $columns is either a single column name or an array of column names |
|---|
| 1037 |
* than only those columns are validated. |
|---|
| 1038 |
* |
|---|
| 1039 |
* NOTICE: This does not apply to primary or foreign keys for now. |
|---|
| 1040 |
* |
|---|
| 1041 |
* @param Relevancy $obj The object to validate. |
|---|
| 1042 |
* @param mixed $cols Column name or array of column names. |
|---|
| 1043 |
* |
|---|
| 1044 |
* @return mixed TRUE if all columns are valid or the error message of the first invalid column. |
|---|
| 1045 |
*/ |
|---|
| 1046 |
public static function doValidate(Relevancy $obj, $cols = null) |
|---|
| 1047 |
{ |
|---|
| 1048 |
$columns = array(); |
|---|
| 1049 |
|
|---|
| 1050 |
if ($cols) { |
|---|
| 1051 |
$dbMap = Propel::getDatabaseMap(RelevancyPeer::DATABASE_NAME); |
|---|
| 1052 |
$tableMap = $dbMap->getTable(RelevancyPeer::TABLE_NAME); |
|---|
| 1053 |
|
|---|
| 1054 |
if (! is_array($cols)) { |
|---|
| 1055 |
$cols = array($cols); |
|---|
| 1056 |
} |
|---|
| 1057 |
|
|---|
| 1058 |
foreach($cols as $colName) { |
|---|
| 1059 |
if ($tableMap->containsColumn($colName)) { |
|---|
| 1060 |
$get = 'get' . $tableMap->getColumn($colName)->getPhpName(); |
|---|
| 1061 |
$columns[$colName] = $obj->$get(); |
|---|
| 1062 |
} |
|---|
| 1063 |
} |
|---|
| 1064 |
} else { |
|---|
| 1065 |
|
|---|
| 1066 |
} |
|---|
| 1067 |
|
|---|
| 1068 |
return BasePeer::doValidate(RelevancyPeer::DATABASE_NAME, RelevancyPeer::TABLE_NAME, $columns); |
|---|
| 1069 |
} |
|---|
| 1070 |
|
|---|
| 1071 |
} |
|---|
| 1072 |
|
|---|
| 1073 |
// static code to register the map builder for this Peer with the main Propel class |
|---|
| 1074 |
if (Propel::isInit()) { |
|---|
| 1075 |
|
|---|
| 1076 |
// so we need to load them here. |
|---|
| 1077 |
try { |
|---|
| 1078 |
BaseRelevancyPeer::getMapBuilder(); |
|---|
| 1079 |
} catch (Exception $e) { |
|---|
| 1080 |
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); |
|---|
| 1081 |
} |
|---|
| 1082 |
} else { |
|---|
| 1083 |
|
|---|
| 1084 |
// now and then it will be loaded when Propel initializes. |
|---|
| 1085 |
require_once 'model/map/RelevancyMapBuilder.php'; |
|---|
| 1086 |
Propel::registerMapBuilder('model.map.RelevancyMapBuilder'); |
|---|
| 1087 |
} |
|---|
| 1088 |
|
|---|