| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
require_once 'propel/util/BasePeer.php'; |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
include_once 'model/SnippetUser.php'; |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
abstract class BaseSnippetUserPeer { |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
const DATABASE_NAME = 'propel'; |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
const TABLE_NAME = 'sn_user'; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
const CLASS_DEFAULT = 'model.SnippetUser'; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
const NUM_COLUMNS = 8; |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
const NUM_LAZY_LOAD_COLUMNS = 0; |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
const ID = 'sn_user.ID'; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
const LOGIN = 'sn_user.LOGIN'; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
const PASSWORD = 'sn_user.PASSWORD'; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
const EMAIL = 'sn_user.EMAIL'; |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
const FIRST_NAME = 'sn_user.FIRST_NAME'; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
const LAST_NAME = 'sn_user.LAST_NAME'; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
const IS_ADMIN = 'sn_user.IS_ADMIN'; |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
const CREATED_AT = 'sn_user.CREATED_AT'; |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
private static $phpNameMap = null; |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
* holds an array of fieldnames |
|---|
| 63 |
* |
|---|
| 64 |
* first dimension keys are the type constants |
|---|
| 65 |
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|---|
| 66 |
*/ |
|---|
| 67 |
private static $fieldNames = array ( |
|---|
| 68 |
BasePeer::TYPE_PHPNAME => array ('Id', 'Login', 'Password', 'Email', 'FirstName', 'LastName', 'IsAdmin', 'CreatedAt', ), |
|---|
| 69 |
BasePeer::TYPE_COLNAME => array (SnippetUserPeer::ID, SnippetUserPeer::LOGIN, SnippetUserPeer::PASSWORD, SnippetUserPeer::EMAIL, SnippetUserPeer::FIRST_NAME, SnippetUserPeer::LAST_NAME, SnippetUserPeer::IS_ADMIN, SnippetUserPeer::CREATED_AT, ), |
|---|
| 70 |
BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'password', 'email', 'first_name', 'last_name', 'is_admin', 'created_at', ), |
|---|
| 71 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) |
|---|
| 72 |
); |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
* holds an array of keys for quick access to the fieldnames array |
|---|
| 76 |
* |
|---|
| 77 |
* first dimension keys are the type constants |
|---|
| 78 |
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 |
|---|
| 79 |
*/ |
|---|
| 80 |
private static $fieldKeys = array ( |
|---|
| 81 |
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Login' => 1, 'Password' => 2, 'Email' => 3, 'FirstName' => 4, 'LastName' => 5, 'IsAdmin' => 6, 'CreatedAt' => 7, ), |
|---|
| 82 |
BasePeer::TYPE_COLNAME => array (SnippetUserPeer::ID => 0, SnippetUserPeer::LOGIN => 1, SnippetUserPeer::PASSWORD => 2, SnippetUserPeer::EMAIL => 3, SnippetUserPeer::FIRST_NAME => 4, SnippetUserPeer::LAST_NAME => 5, SnippetUserPeer::IS_ADMIN => 6, SnippetUserPeer::CREATED_AT => 7, ), |
|---|
| 83 |
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'password' => 2, 'email' => 3, 'first_name' => 4, 'last_name' => 5, 'is_admin' => 6, 'created_at' => 7, ), |
|---|
| 84 |
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) |
|---|
| 85 |
); |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
* @return MapBuilder the map builder for this peer |
|---|
| 89 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 90 |
* rethrown wrapped into a PropelException. |
|---|
| 91 |
*/ |
|---|
| 92 |
public static function getMapBuilder() |
|---|
| 93 |
{ |
|---|
| 94 |
include_once 'model/map/SnippetUserMapBuilder.php'; |
|---|
| 95 |
return BasePeer::getMapBuilder('model.map.SnippetUserMapBuilder'); |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
* Gets a map (hash) of PHP names to DB column names. |
|---|
| 99 |
* |
|---|
| 100 |
* @return array The PHP to DB name map for this peer |
|---|
| 101 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 102 |
* rethrown wrapped into a PropelException. |
|---|
| 103 |
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. |
|---|
| 104 |
*/ |
|---|
| 105 |
public static function getPhpNameMap() |
|---|
| 106 |
{ |
|---|
| 107 |
if (self::$phpNameMap === null) { |
|---|
| 108 |
$map = SnippetUserPeer::getTableMap(); |
|---|
| 109 |
$columns = $map->getColumns(); |
|---|
| 110 |
$nameMap = array(); |
|---|
| 111 |
foreach ($columns as $column) { |
|---|
| 112 |
$nameMap[$column->getPhpName()] = $column->getColumnName(); |
|---|
| 113 |
} |
|---|
| 114 |
self::$phpNameMap = $nameMap; |
|---|
| 115 |
} |
|---|
| 116 |
return self::$phpNameMap; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
* Translates a fieldname to another type |
|---|
| 120 |
* |
|---|
| 121 |
* @param string $name field name |
|---|
| 122 |
* @param string $fromType One of the class type constants TYPE_PHPNAME, |
|---|
| 123 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 124 |
* @param string $toType One of the class type constants |
|---|
| 125 |
* @return string translated name of the field. |
|---|
| 126 |
*/ |
|---|
| 127 |
static public function translateFieldName($name, $fromType, $toType) |
|---|
| 128 |
{ |
|---|
| 129 |
$toNames = self::getFieldNames($toType); |
|---|
| 130 |
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; |
|---|
| 131 |
if ($key === null) { |
|---|
| 132 |
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); |
|---|
| 133 |
} |
|---|
| 134 |
return $toNames[$key]; |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
* Returns an array of of field names. |
|---|
| 139 |
* |
|---|
| 140 |
* @param string $type The type of fieldnames to return: |
|---|
| 141 |
* One of the class type constants TYPE_PHPNAME, |
|---|
| 142 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 143 |
* @return array A list of field names |
|---|
| 144 |
*/ |
|---|
| 145 |
|
|---|
| 146 |
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) |
|---|
| 147 |
{ |
|---|
| 148 |
if (!array_key_exists($type, self::$fieldNames)) { |
|---|
| 149 |
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.'); |
|---|
| 150 |
} |
|---|
| 151 |
return self::$fieldNames[$type]; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
* Convenience method which changes table.column to alias.column. |
|---|
| 156 |
* |
|---|
| 157 |
* Using this method you can maintain SQL abstraction while using column aliases. |
|---|
| 158 |
* <code> |
|---|
| 159 |
* $c->addAlias("alias1", TablePeer::TABLE_NAME); |
|---|
| 160 |
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); |
|---|
| 161 |
* </code> |
|---|
| 162 |
* @param string $alias The alias for the current table. |
|---|
| 163 |
* @param string $column The column name for current table. (i.e. SnippetUserPeer::COLUMN_NAME). |
|---|
| 164 |
* @return string |
|---|
| 165 |
*/ |
|---|
| 166 |
public static function alias($alias, $column) |
|---|
| 167 |
{ |
|---|
| 168 |
return str_replace(SnippetUserPeer::TABLE_NAME.'.', $alias.'.', $column); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
* Add all the columns needed to create a new object. |
|---|
| 173 |
* |
|---|
| 174 |
* Note: any columns that were marked with lazyLoad="true" in the |
|---|
| 175 |
* XML schema will not be added to the select list and only loaded |
|---|
| 176 |
* on demand. |
|---|
| 177 |
* |
|---|
| 178 |
* @param criteria object containing the columns to add. |
|---|
| 179 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 180 |
* rethrown wrapped into a PropelException. |
|---|
| 181 |
*/ |
|---|
| 182 |
public static function addSelectColumns(Criteria $criteria) |
|---|
| 183 |
{ |
|---|
| 184 |
|
|---|
| 185 |
$criteria->addSelectColumn(SnippetUserPeer::ID); |
|---|
| 186 |
|
|---|
| 187 |
$criteria->addSelectColumn(SnippetUserPeer::LOGIN); |
|---|
| 188 |
|
|---|
| 189 |
$criteria->addSelectColumn(SnippetUserPeer::PASSWORD); |
|---|
| 190 |
|
|---|
| 191 |
$criteria->addSelectColumn(SnippetUserPeer::EMAIL); |
|---|
| 192 |
|
|---|
| 193 |
$criteria->addSelectColumn(SnippetUserPeer::FIRST_NAME); |
|---|
| 194 |
|
|---|
| 195 |
$criteria->addSelectColumn(SnippetUserPeer::LAST_NAME); |
|---|
| 196 |
|
|---|
| 197 |
$criteria->addSelectColumn(SnippetUserPeer::IS_ADMIN); |
|---|
| 198 |
|
|---|
| 199 |
$criteria->addSelectColumn(SnippetUserPeer::CREATED_AT); |
|---|
| 200 |
|
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
const COUNT = 'COUNT(sn_user.ID)'; |
|---|
| 204 |
const COUNT_DISTINCT = 'COUNT(DISTINCT sn_user.ID)'; |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
* Returns the number of rows matching criteria. |
|---|
| 208 |
* |
|---|
| 209 |
* @param Criteria $criteria |
|---|
| 210 |
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). |
|---|
| 211 |
* @param Connection $con |
|---|
| 212 |
* @return int Number of matching rows. |
|---|
| 213 |
*/ |
|---|
| 214 |
public static function doCount(Criteria $criteria, $distinct = false, $con = null) |
|---|
| 215 |
{ |
|---|
| 216 |
|
|---|
| 217 |
$criteria = clone $criteria; |
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
$criteria->clearSelectColumns()->clearOrderByColumns(); |
|---|
| 221 |
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
|---|
| 222 |
$criteria->addSelectColumn(SnippetUserPeer::COUNT_DISTINCT); |
|---|
| 223 |
} else { |
|---|
| 224 |
$criteria->addSelectColumn(SnippetUserPeer::COUNT); |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
foreach($criteria->getGroupByColumns() as $column) |
|---|
| 229 |
{ |
|---|
| 230 |
$criteria->addSelectColumn($column); |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
$rs = SnippetUserPeer::doSelectRS($criteria, $con); |
|---|
| 234 |
if ($rs->next()) { |
|---|
| 235 |
return $rs->getInt(1); |
|---|
| 236 |
} else { |
|---|
| 237 |
|
|---|
| 238 |
return 0; |
|---|
| 239 |
} |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
* Method to select one object from the DB. |
|---|
| 243 |
* |
|---|
| 244 |
* @param Criteria $criteria object used to create the SELECT statement. |
|---|
| 245 |
* @param Connection $con |
|---|
| 246 |
* @return SnippetUser |
|---|
| 247 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 248 |
* rethrown wrapped into a PropelException. |
|---|
| 249 |
*/ |
|---|
| 250 |
public static function doSelectOne(Criteria $criteria, $con = null) |
|---|
| 251 |
{ |
|---|
| 252 |
$critcopy = clone $criteria; |
|---|
| 253 |
$critcopy->setLimit(1); |
|---|
| 254 |
$objects = SnippetUserPeer::doSelect($critcopy, $con); |
|---|
| 255 |
if ($objects) { |
|---|
| 256 |
return $objects[0]; |
|---|
| 257 |
} |
|---|
| 258 |
return null; |
|---|
| 259 |
} |
|---|
| 260 |
|
|---|
| 261 |
* Method to do selects. |
|---|
| 262 |
* |
|---|
| 263 |
* @param Criteria $criteria The Criteria object used to build the SELECT statement. |
|---|
| 264 |
* @param Connection $con |
|---|
| 265 |
* @return array Array of selected Objects |
|---|
| 266 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 267 |
* rethrown wrapped into a PropelException. |
|---|
| 268 |
*/ |
|---|
| 269 |
public static function doSelect(Criteria $criteria, $con = null) |
|---|
| 270 |
{ |
|---|
| 271 |
return SnippetUserPeer::populateObjects(SnippetUserPeer::doSelectRS($criteria, $con)); |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
* Prepares the Criteria object and uses the parent doSelect() |
|---|
| 275 |
* method to get a ResultSet. |
|---|
| 276 |
* |
|---|
| 277 |
* Use this method directly if you want to just get the resultset |
|---|
| 278 |
* (instead of an array of objects). |
|---|
| 279 |
* |
|---|
| 280 |
* @param Criteria $criteria The Criteria object used to build the SELECT statement. |
|---|
| 281 |
* @param Connection $con the connection to use |
|---|
| 282 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 283 |
* rethrown wrapped into a PropelException. |
|---|
| 284 |
* @return ResultSet The resultset object with numerically-indexed fields. |
|---|
| 285 |
* @see BasePeer::doSelect() |
|---|
| 286 |
*/ |
|---|
| 287 |
public static function doSelectRS(Criteria $criteria, $con = null) |
|---|
| 288 |
{ |
|---|
| 289 |
if ($con === null) { |
|---|
| 290 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 291 |
} |
|---|
| 292 |
|
|---|
| 293 |
if (!$criteria->getSelectColumns()) { |
|---|
| 294 |
$criteria = clone $criteria; |
|---|
| 295 |
SnippetUserPeer::addSelectColumns($criteria); |
|---|
| 296 |
} |
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
// rows indexed numerically. |
|---|
| 303 |
return BasePeer::doSelect($criteria, $con); |
|---|
| 304 |
} |
|---|
| 305 |
|
|---|
| 306 |
* The returned array will contain objects of the default type or |
|---|
| 307 |
* objects that inherit from the default. |
|---|
| 308 |
* |
|---|
| 309 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 310 |
* rethrown wrapped into a PropelException. |
|---|
| 311 |
*/ |
|---|
| 312 |
public static function populateObjects(ResultSet $rs) |
|---|
| 313 |
{ |
|---|
| 314 |
$results = array(); |
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
$cls = SnippetUserPeer::getOMClass(); |
|---|
| 318 |
$cls = Propel::import($cls); |
|---|
| 319 |
|
|---|
| 320 |
while($rs->next()) { |
|---|
| 321 |
|
|---|
| 322 |
$obj = new $cls(); |
|---|
| 323 |
$obj->hydrate($rs); |
|---|
| 324 |
$results[] = $obj; |
|---|
| 325 |
|
|---|
| 326 |
} |
|---|
| 327 |
return $results; |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
* Returns the TableMap related to this peer. |
|---|
| 331 |
* This method is not needed for general use but a specific application could have a need. |
|---|
| 332 |
* @return TableMap |
|---|
| 333 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 334 |
* rethrown wrapped into a PropelException. |
|---|
| 335 |
*/ |
|---|
| 336 |
public static function getTableMap() |
|---|
| 337 |
{ |
|---|
| 338 |
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
* The class that the Peer will make instances of. |
|---|
| 343 |
* |
|---|
| 344 |
* This uses a dot-path notation which is tranalted into a path |
|---|
| 345 |
* relative to a location on the PHP include_path. |
|---|
| 346 |
* (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|---|
| 347 |
* |
|---|
| 348 |
* @return string path.to.ClassName |
|---|
| 349 |
*/ |
|---|
| 350 |
public static function getOMClass() |
|---|
| 351 |
{ |
|---|
| 352 |
return SnippetUserPeer::CLASS_DEFAULT; |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
* Method perform an INSERT on the database, given a SnippetUser or Criteria object. |
|---|
| 357 |
* |
|---|
| 358 |
* @param mixed $values Criteria or SnippetUser object containing data that is used to create the INSERT statement. |
|---|
| 359 |
* @param Connection $con the connection to use |
|---|
| 360 |
* @return mixed The new primary key. |
|---|
| 361 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 362 |
* rethrown wrapped into a PropelException. |
|---|
| 363 |
*/ |
|---|
| 364 |
public static function doInsert($values, $con = null) |
|---|
| 365 |
{ |
|---|
| 366 |
if ($con === null) { |
|---|
| 367 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
if ($values instanceof Criteria) { |
|---|
| 371 |
$criteria = clone $values; |
|---|
| 372 |
} else { |
|---|
| 373 |
$criteria = $values->buildCriteria(); |
|---|
| 374 |
} |
|---|
| 375 |
|
|---|
| 376 |
$criteria->remove(SnippetUserPeer::ID); |
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 |
// Set the correct dbName |
|---|
| 380 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 381 |
|
|---|
| 382 |
try { |
|---|
| 383 |
|
|---|
| 384 |
// for more than one table (I guess, conceivably) |
|---|
| 385 |
$con->begin(); |
|---|
| 386 |
$pk = BasePeer::doInsert($criteria, $con); |
|---|
| 387 |
$con->commit(); |
|---|
| 388 |
} catch(PropelException $e) { |
|---|
| 389 |
$con->rollback(); |
|---|
| 390 |
throw $e; |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
return $pk; |
|---|
| 394 |
} |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
* Method perform an UPDATE on the database, given a SnippetUser or Criteria object. |
|---|
| 398 |
* |
|---|
| 399 |
* @param mixed $values Criteria or SnippetUser object containing data that is used to create the UPDATE statement. |
|---|
| 400 |
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions). |
|---|
| 401 |
* @return int The number of affected rows (if supported by underlying database driver). |
|---|
| 402 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 403 |
* rethrown wrapped into a PropelException. |
|---|
| 404 |
*/ |
|---|
| 405 |
public static function doUpdate($values, $con = null) |
|---|
| 406 |
{ |
|---|
| 407 |
if ($con === null) { |
|---|
| 408 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 409 |
} |
|---|
| 410 |
|
|---|
| 411 |
$selectCriteria = new Criteria(self::DATABASE_NAME); |
|---|
| 412 |
|
|---|
| 413 |
if ($values instanceof Criteria) { |
|---|
| 414 |
$criteria = clone $values; |
|---|
| 415 |
|
|---|
| 416 |
$comparison = $criteria->getComparison(SnippetUserPeer::ID); |
|---|
| 417 |
$selectCriteria->add(SnippetUserPeer::ID, $criteria->remove(SnippetUserPeer::ID), $comparison); |
|---|
| 418 |
|
|---|
| 419 |
} else { |
|---|
| 420 |
$criteria = $values->buildCriteria(); |
|---|
| 421 |
$selectCriteria = $values->buildPkeyCriteria(); |
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 426 |
|
|---|
| 427 |
return BasePeer::doUpdate($selectCriteria, $criteria, $con); |
|---|
| 428 |
} |
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
* Method to DELETE all rows from the sn_user table. |
|---|
| 432 |
* |
|---|
| 433 |
* @return int The number of affected rows (if supported by underlying database driver). |
|---|
| 434 |
*/ |
|---|
| 435 |
public static function doDeleteAll($con = null) |
|---|
| 436 |
{ |
|---|
| 437 |
if ($con === null) { |
|---|
| 438 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 439 |
} |
|---|
| 440 |
$affectedRows = 0; |
|---|
| 441 |
try { |
|---|
| 442 |
|
|---|
| 443 |
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
|---|
| 444 |
$con->begin(); |
|---|
| 445 |
$affectedRows += BasePeer::doDeleteAll(SnippetUserPeer::TABLE_NAME, $con); |
|---|
| 446 |
$con->commit(); |
|---|
| 447 |
return $affectedRows; |
|---|
| 448 |
} catch (PropelException $e) { |
|---|
| 449 |
$con->rollback(); |
|---|
| 450 |
throw $e; |
|---|
| 451 |
} |
|---|
| 452 |
} |
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
* Method perform a DELETE on the database, given a SnippetUser or Criteria object OR a primary key value. |
|---|
| 456 |
* |
|---|
| 457 |
* @param mixed $values Criteria or SnippetUser object or primary key or array of primary keys |
|---|
| 458 |
* which is used to create the DELETE statement |
|---|
| 459 |
* @param Connection $con the connection to use |
|---|
| 460 |
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|---|
| 461 |
* if supported by native driver or if emulated using Propel. |
|---|
| 462 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 463 |
* rethrown wrapped into a PropelException. |
|---|
| 464 |
*/ |
|---|
| 465 |
public static function doDelete($values, $con = null) |
|---|
| 466 |
{ |
|---|
| 467 |
if ($con === null) { |
|---|
| 468 |
$con = Propel::getConnection(SnippetUserPeer::DATABASE_NAME); |
|---|
| 469 |
} |
|---|
| 470 |
|
|---|
| 471 |
if ($values instanceof Criteria) { |
|---|
| 472 |
$criteria = clone $values; |
|---|
| 473 |
} elseif ($values instanceof SnippetUser) { |
|---|
| 474 |
|
|---|
| 475 |
$criteria = $values->buildPkeyCriteria(); |
|---|
| 476 |
} else { |
|---|
| 477 |
|
|---|
| 478 |
$criteria = new Criteria(self::DATABASE_NAME); |
|---|
| 479 |
$criteria->add(SnippetUserPeer::ID, (array) $values, Criteria::IN); |
|---|
| 480 |
} |
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
$criteria->setDbName(self::DATABASE_NAME); |
|---|
| 484 |
|
|---|
| 485 |
$affectedRows = 0; |
|---|
| 486 |
|
|---|
| 487 |
try { |
|---|
| 488 |
|
|---|
| 489 |
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
|---|
| 490 |
$con->begin(); |
|---|
| 491 |
|
|---|
| 492 |
$affectedRows += BasePeer::doDelete($criteria, $con); |
|---|
| 493 |
$con->commit(); |
|---|
| 494 |
return $affectedRows; |
|---|
| 495 |
} catch (PropelException $e) { |
|---|
| 496 |
$con->rollback(); |
|---|
| 497 |
throw $e; |
|---|
| 498 |
} |
|---|
| 499 |
} |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
* Validates all modified columns of given SnippetUser object. |
|---|
| 503 |
* If parameter $columns is either a single column name or an array of column names |
|---|
| 504 |
* than only those columns are validated. |
|---|
| 505 |
* |
|---|
| 506 |
* NOTICE: This does not apply to primary or foreign keys for now. |
|---|
| 507 |
* |
|---|
| 508 |
* @param SnippetUser $obj The object to validate. |
|---|
| 509 |
* @param mixed $cols Column name or array of column names. |
|---|
| 510 |
* |
|---|
| 511 |
* @return mixed TRUE if all columns are valid or the error message of the first invalid column. |
|---|
| 512 |
*/ |
|---|
| 513 |
public static function doValidate(SnippetUser $obj, $cols = null) |
|---|
| 514 |
{ |
|---|
| 515 |
$columns = array(); |
|---|
| 516 |
|
|---|
| 517 |
if ($cols) { |
|---|
| 518 |
$dbMap = Propel::getDatabaseMap(SnippetUserPeer::DATABASE_NAME); |
|---|
| 519 |
$tableMap = $dbMap->getTable(SnippetUserPeer::TABLE_NAME); |
|---|
| 520 |
|
|---|
| 521 |
if (! is_array($cols)) { |
|---|
| 522 |
$cols = array($cols); |
|---|
| 523 |
} |
|---|
| 524 |
|
|---|
| 525 |
foreach($cols as $colName) { |
|---|
| 526 |
if ($tableMap->containsColumn($colName)) { |
|---|
| 527 |
$get = 'get' . $tableMap->getColumn($colName)->getPhpName(); |
|---|
| 528 |
$columns[$colName] = $obj->$get(); |
|---|
| 529 |
} |
|---|
| 530 |
} |
|---|
| 531 |
} else { |
|---|
| 532 |
|
|---|
| 533 |
} |
|---|
| 534 |
|
|---|
| 535 |
$res = BasePeer::doValidate(SnippetUserPeer::DATABASE_NAME, SnippetUserPeer::TABLE_NAME, $columns); |
|---|
| 536 |
if ($res !== true) { |
|---|
| 537 |
$request = sfContext::getInstance()->getRequest(); |
|---|
| 538 |
foreach ($res as $failed) { |
|---|
| 539 |
$col = SnippetUserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); |
|---|
| 540 |
$request->setError($col, $failed->getMessage()); |
|---|
| 541 |
} |
|---|
| 542 |
} |
|---|
| 543 |
|
|---|
| 544 |
return $res; |
|---|
| 545 |
} |
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
* Retrieve a single object by pkey. |
|---|
| 549 |
* |
|---|
| 550 |
* @param mixed $pk the primary key. |
|---|
| 551 |
* @param Connection $con the connection to use |
|---|
| 552 |
* @return SnippetUser |
|---|
| 553 |
*/ |
|---|
| 554 |
public static function retrieveByPK($pk, $con = null) |
|---|
| 555 |
{ |
|---|
| 556 |
if ($con === null) { |
|---|
| 557 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
$criteria = new Criteria(SnippetUserPeer::DATABASE_NAME); |
|---|
| 561 |
|
|---|
| 562 |
$criteria->add(SnippetUserPeer::ID, $pk); |
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
$v = SnippetUserPeer::doSelect($criteria, $con); |
|---|
| 566 |
|
|---|
| 567 |
return !empty($v) > 0 ? $v[0] : null; |
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 |
* Retrieve multiple objects by pkey. |
|---|
| 572 |
* |
|---|
| 573 |
* @param array $pks List of primary keys |
|---|
| 574 |
* @param Connection $con the connection to use |
|---|
| 575 |
* @throws PropelException Any exceptions caught during processing will be |
|---|
| 576 |
* rethrown wrapped into a PropelException. |
|---|
| 577 |
*/ |
|---|
| 578 |
public static function retrieveByPKs($pks, $con = null) |
|---|
| 579 |
{ |
|---|
| 580 |
if ($con === null) { |
|---|
| 581 |
$con = Propel::getConnection(self::DATABASE_NAME); |
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
$objs = null; |
|---|
| 585 |
if (empty($pks)) { |
|---|
| 586 |
$objs = array(); |
|---|
| 587 |
} else { |
|---|
| 588 |
$criteria = new Criteria(); |
|---|
| 589 |
$criteria->add(SnippetUserPeer::ID, $pks, Criteria::IN); |
|---|
| 590 |
$objs = SnippetUserPeer::doSelect($criteria, $con); |
|---|
| 591 |
} |
|---|
| 592 |
return $objs; |
|---|
| 593 |
} |
|---|
| 594 |
|
|---|
| 595 |
} |
|---|
| 596 |
|
|---|
| 597 |
// static code to register the map builder for this Peer with the main Propel class |
|---|
| 598 |
if (Propel::isInit()) { |
|---|
| 599 |
|
|---|
| 600 |
// so we need to load them here. |
|---|
| 601 |
try { |
|---|
| 602 |
BaseSnippetUserPeer::getMapBuilder(); |
|---|
| 603 |
} catch (Exception $e) { |
|---|
| 604 |
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); |
|---|
| 605 |
} |
|---|
| 606 |
} else { |
|---|
| 607 |
|
|---|
| 608 |
// now and then it will be loaded when Propel initializes. |
|---|
| 609 |
require_once 'model/map/SnippetUserMapBuilder.php'; |
|---|
| 610 |
Propel::registerMapBuilder('model.map.SnippetUserMapBuilder'); |
|---|
| 611 |
} |
|---|
| 612 |
|
|---|