initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

2491
lib/model/om/BaseClient.php Executable file

File diff suppressed because it is too large Load Diff

729
lib/model/om/BaseClientPeer.php Executable file
View File

@ -0,0 +1,729 @@
<?php
abstract class BaseClientPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'client';
const CLASS_DEFAULT = 'lib.model.Client';
const NUM_COLUMNS = 42;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'client.ID';
const LOCATION_ID = 'client.LOCATION_ID';
const CLIENT_IDENTIFICATION = 'client.CLIENT_IDENTIFICATION';
const CLIENT_NAME = 'client.CLIENT_NAME';
const ADDRESS = 'client.ADDRESS';
const ADDRESS_2 = 'client.ADDRESS_2';
const CITY = 'client.CITY';
const STATE = 'client.STATE';
const ZIP = 'client.ZIP';
const ATTN = 'client.ATTN';
const EMAIL = 'client.EMAIL';
const PHONE = 'client.PHONE';
const EXT = 'client.EXT';
const CATEGORY = 'client.CATEGORY';
const NOTES = 'client.NOTES';
const ALL_DEVICES = 'client.ALL_DEVICES';
const FREQ_APPROVED = 'client.FREQ_APPROVED';
const FREQ_LOCKED = 'client.FREQ_LOCKED';
const CREATED_AT = 'client.CREATED_AT';
const UPDATED_AT = 'client.UPDATED_AT';
const FREQUENCY = 'client.FREQUENCY';
const FREQUENCY_ANNUAL = 'client.FREQUENCY_ANNUAL';
const FREQUENCY_SEMI = 'client.FREQUENCY_SEMI';
const FREQUENCY_QUARTERLY = 'client.FREQUENCY_QUARTERLY';
const FREQUENCY_STERILIZER = 'client.FREQUENCY_STERILIZER';
const FREQUENCY_TG = 'client.FREQUENCY_TG';
const FREQUENCY_ERT = 'client.FREQUENCY_ERT';
const FREQUENCY_RAE = 'client.FREQUENCY_RAE';
const FREQUENCY_MEDGAS = 'client.FREQUENCY_MEDGAS';
const FREQUENCY_IMAGING = 'client.FREQUENCY_IMAGING';
const FREQUENCY_NEPTUNE = 'client.FREQUENCY_NEPTUNE';
const FREQUENCY_ANESTHESIA = 'client.FREQUENCY_ANESTHESIA';
const ANESTHESIA = 'client.ANESTHESIA';
const MEDGAS = 'client.MEDGAS';
const REQUIRE_COORDS_UPDATE = 'client.REQUIRE_COORDS_UPDATE';
const ADDRESSTYPE = 'client.ADDRESSTYPE';
const SECONDARY_ADDRESS = 'client.SECONDARY_ADDRESS';
const SECONDARY_ADDRESS_2 = 'client.SECONDARY_ADDRESS_2';
const SECONDARY_CITY = 'client.SECONDARY_CITY';
const SECONDARY_STATE = 'client.SECONDARY_STATE';
const SECONDARY_ZIP = 'client.SECONDARY_ZIP';
const SECONDARY_ATTN = 'client.SECONDARY_ATTN';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'LocationId', 'ClientIdentification', 'ClientName', 'Address', 'Address2', 'City', 'State', 'Zip', 'Attn', 'Email', 'Phone', 'Ext', 'Category', 'Notes', 'AllDevices', 'FreqApproved', 'FreqLocked', 'CreatedAt', 'UpdatedAt', 'Frequency', 'FrequencyAnnual', 'FrequencySemi', 'FrequencyQuarterly', 'FrequencySterilizer', 'FrequencyTg', 'FrequencyErt', 'FrequencyRae', 'FrequencyMedgas', 'FrequencyImaging', 'FrequencyNeptune', 'FrequencyAnesthesia', 'Anesthesia', 'Medgas', 'RequireCoordsUpdate', 'Addresstype', 'SecondaryAddress', 'SecondaryAddress2', 'SecondaryCity', 'SecondaryState', 'SecondaryZip', 'SecondaryAttn', ),
BasePeer::TYPE_COLNAME => array (ClientPeer::ID, ClientPeer::LOCATION_ID, ClientPeer::CLIENT_IDENTIFICATION, ClientPeer::CLIENT_NAME, ClientPeer::ADDRESS, ClientPeer::ADDRESS_2, ClientPeer::CITY, ClientPeer::STATE, ClientPeer::ZIP, ClientPeer::ATTN, ClientPeer::EMAIL, ClientPeer::PHONE, ClientPeer::EXT, ClientPeer::CATEGORY, ClientPeer::NOTES, ClientPeer::ALL_DEVICES, ClientPeer::FREQ_APPROVED, ClientPeer::FREQ_LOCKED, ClientPeer::CREATED_AT, ClientPeer::UPDATED_AT, ClientPeer::FREQUENCY, ClientPeer::FREQUENCY_ANNUAL, ClientPeer::FREQUENCY_SEMI, ClientPeer::FREQUENCY_QUARTERLY, ClientPeer::FREQUENCY_STERILIZER, ClientPeer::FREQUENCY_TG, ClientPeer::FREQUENCY_ERT, ClientPeer::FREQUENCY_RAE, ClientPeer::FREQUENCY_MEDGAS, ClientPeer::FREQUENCY_IMAGING, ClientPeer::FREQUENCY_NEPTUNE, ClientPeer::FREQUENCY_ANESTHESIA, ClientPeer::ANESTHESIA, ClientPeer::MEDGAS, ClientPeer::REQUIRE_COORDS_UPDATE, ClientPeer::ADDRESSTYPE, ClientPeer::SECONDARY_ADDRESS, ClientPeer::SECONDARY_ADDRESS_2, ClientPeer::SECONDARY_CITY, ClientPeer::SECONDARY_STATE, ClientPeer::SECONDARY_ZIP, ClientPeer::SECONDARY_ATTN, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'location_id', 'client_identification', 'client_name', 'address', 'address_2', 'city', 'state', 'zip', 'attn', 'email', 'phone', 'ext', 'category', 'notes', 'all_devices', 'freq_approved', 'freq_locked', 'created_at', 'updated_at', 'frequency', 'frequency_annual', 'frequency_semi', 'frequency_quarterly', 'frequency_sterilizer', 'frequency_tg', 'frequency_ert', 'frequency_rae', 'frequency_medgas', 'frequency_imaging', 'frequency_neptune', 'frequency_anesthesia', 'anesthesia', 'medgas', 'require_coords_update', 'addressType', 'secondary_address', 'secondary_address_2', 'secondary_city', 'secondary_state', 'secondary_zip', 'secondary_attn', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'LocationId' => 1, 'ClientIdentification' => 2, 'ClientName' => 3, 'Address' => 4, 'Address2' => 5, 'City' => 6, 'State' => 7, 'Zip' => 8, 'Attn' => 9, 'Email' => 10, 'Phone' => 11, 'Ext' => 12, 'Category' => 13, 'Notes' => 14, 'AllDevices' => 15, 'FreqApproved' => 16, 'FreqLocked' => 17, 'CreatedAt' => 18, 'UpdatedAt' => 19, 'Frequency' => 20, 'FrequencyAnnual' => 21, 'FrequencySemi' => 22, 'FrequencyQuarterly' => 23, 'FrequencySterilizer' => 24, 'FrequencyTg' => 25, 'FrequencyErt' => 26, 'FrequencyRae' => 27, 'FrequencyMedgas' => 28, 'FrequencyImaging' => 29, 'FrequencyNeptune' => 30, 'FrequencyAnesthesia' => 31, 'Anesthesia' => 32, 'Medgas' => 33, 'RequireCoordsUpdate' => 34, 'Addresstype' => 35, 'SecondaryAddress' => 36, 'SecondaryAddress2' => 37, 'SecondaryCity' => 38, 'SecondaryState' => 39, 'SecondaryZip' => 40, 'SecondaryAttn' => 41, ),
BasePeer::TYPE_COLNAME => array (ClientPeer::ID => 0, ClientPeer::LOCATION_ID => 1, ClientPeer::CLIENT_IDENTIFICATION => 2, ClientPeer::CLIENT_NAME => 3, ClientPeer::ADDRESS => 4, ClientPeer::ADDRESS_2 => 5, ClientPeer::CITY => 6, ClientPeer::STATE => 7, ClientPeer::ZIP => 8, ClientPeer::ATTN => 9, ClientPeer::EMAIL => 10, ClientPeer::PHONE => 11, ClientPeer::EXT => 12, ClientPeer::CATEGORY => 13, ClientPeer::NOTES => 14, ClientPeer::ALL_DEVICES => 15, ClientPeer::FREQ_APPROVED => 16, ClientPeer::FREQ_LOCKED => 17, ClientPeer::CREATED_AT => 18, ClientPeer::UPDATED_AT => 19, ClientPeer::FREQUENCY => 20, ClientPeer::FREQUENCY_ANNUAL => 21, ClientPeer::FREQUENCY_SEMI => 22, ClientPeer::FREQUENCY_QUARTERLY => 23, ClientPeer::FREQUENCY_STERILIZER => 24, ClientPeer::FREQUENCY_TG => 25, ClientPeer::FREQUENCY_ERT => 26, ClientPeer::FREQUENCY_RAE => 27, ClientPeer::FREQUENCY_MEDGAS => 28, ClientPeer::FREQUENCY_IMAGING => 29, ClientPeer::FREQUENCY_NEPTUNE => 30, ClientPeer::FREQUENCY_ANESTHESIA => 31, ClientPeer::ANESTHESIA => 32, ClientPeer::MEDGAS => 33, ClientPeer::REQUIRE_COORDS_UPDATE => 34, ClientPeer::ADDRESSTYPE => 35, ClientPeer::SECONDARY_ADDRESS => 36, ClientPeer::SECONDARY_ADDRESS_2 => 37, ClientPeer::SECONDARY_CITY => 38, ClientPeer::SECONDARY_STATE => 39, ClientPeer::SECONDARY_ZIP => 40, ClientPeer::SECONDARY_ATTN => 41, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'location_id' => 1, 'client_identification' => 2, 'client_name' => 3, 'address' => 4, 'address_2' => 5, 'city' => 6, 'state' => 7, 'zip' => 8, 'attn' => 9, 'email' => 10, 'phone' => 11, 'ext' => 12, 'category' => 13, 'notes' => 14, 'all_devices' => 15, 'freq_approved' => 16, 'freq_locked' => 17, 'created_at' => 18, 'updated_at' => 19, 'frequency' => 20, 'frequency_annual' => 21, 'frequency_semi' => 22, 'frequency_quarterly' => 23, 'frequency_sterilizer' => 24, 'frequency_tg' => 25, 'frequency_ert' => 26, 'frequency_rae' => 27, 'frequency_medgas' => 28, 'frequency_imaging' => 29, 'frequency_neptune' => 30, 'frequency_anesthesia' => 31, 'anesthesia' => 32, 'medgas' => 33, 'require_coords_update' => 34, 'addressType' => 35, 'secondary_address' => 36, 'secondary_address_2' => 37, 'secondary_city' => 38, 'secondary_state' => 39, 'secondary_zip' => 40, 'secondary_attn' => 41, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/ClientMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.ClientMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = ClientPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(ClientPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(ClientPeer::ID);
$criteria->addSelectColumn(ClientPeer::LOCATION_ID);
$criteria->addSelectColumn(ClientPeer::CLIENT_IDENTIFICATION);
$criteria->addSelectColumn(ClientPeer::CLIENT_NAME);
$criteria->addSelectColumn(ClientPeer::ADDRESS);
$criteria->addSelectColumn(ClientPeer::ADDRESS_2);
$criteria->addSelectColumn(ClientPeer::CITY);
$criteria->addSelectColumn(ClientPeer::STATE);
$criteria->addSelectColumn(ClientPeer::ZIP);
$criteria->addSelectColumn(ClientPeer::ATTN);
$criteria->addSelectColumn(ClientPeer::EMAIL);
$criteria->addSelectColumn(ClientPeer::PHONE);
$criteria->addSelectColumn(ClientPeer::EXT);
$criteria->addSelectColumn(ClientPeer::CATEGORY);
$criteria->addSelectColumn(ClientPeer::NOTES);
$criteria->addSelectColumn(ClientPeer::ALL_DEVICES);
$criteria->addSelectColumn(ClientPeer::FREQ_APPROVED);
$criteria->addSelectColumn(ClientPeer::FREQ_LOCKED);
$criteria->addSelectColumn(ClientPeer::CREATED_AT);
$criteria->addSelectColumn(ClientPeer::UPDATED_AT);
$criteria->addSelectColumn(ClientPeer::FREQUENCY);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_ANNUAL);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_SEMI);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_QUARTERLY);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_STERILIZER);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_TG);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_ERT);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_RAE);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_MEDGAS);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_IMAGING);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_NEPTUNE);
$criteria->addSelectColumn(ClientPeer::FREQUENCY_ANESTHESIA);
$criteria->addSelectColumn(ClientPeer::ANESTHESIA);
$criteria->addSelectColumn(ClientPeer::MEDGAS);
$criteria->addSelectColumn(ClientPeer::REQUIRE_COORDS_UPDATE);
$criteria->addSelectColumn(ClientPeer::ADDRESSTYPE);
$criteria->addSelectColumn(ClientPeer::SECONDARY_ADDRESS);
$criteria->addSelectColumn(ClientPeer::SECONDARY_ADDRESS_2);
$criteria->addSelectColumn(ClientPeer::SECONDARY_CITY);
$criteria->addSelectColumn(ClientPeer::SECONDARY_STATE);
$criteria->addSelectColumn(ClientPeer::SECONDARY_ZIP);
$criteria->addSelectColumn(ClientPeer::SECONDARY_ATTN);
}
const COUNT = 'COUNT(client.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT client.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(ClientPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(ClientPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = ClientPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = ClientPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return ClientPeer::populateObjects(ClientPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
ClientPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = ClientPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinLocation(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(ClientPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(ClientPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(ClientPeer::LOCATION_ID, LocationPeer::ID);
$rs = ClientPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinLocation(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
ClientPeer::addSelectColumns($c);
$startcol = (ClientPeer::NUM_COLUMNS - ClientPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
LocationPeer::addSelectColumns($c);
$c->addJoin(ClientPeer::LOCATION_ID, LocationPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = LocationPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getLocation(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addClient($obj1); break;
}
}
if ($newObject) {
$obj2->initClients();
$obj2->addClient($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(ClientPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(ClientPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(ClientPeer::LOCATION_ID, LocationPeer::ID);
$rs = ClientPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
ClientPeer::addSelectColumns($c);
$startcol2 = (ClientPeer::NUM_COLUMNS - ClientPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
LocationPeer::addSelectColumns($c);
$startcol3 = $startcol2 + LocationPeer::NUM_COLUMNS;
$c->addJoin(ClientPeer::LOCATION_ID, LocationPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = LocationPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getLocation(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addClient($obj1); break;
}
}
if ($newObject) {
$obj2->initClients();
$obj2->addClient($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return ClientPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(ClientPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(ClientPeer::ID);
$selectCriteria->add(ClientPeer::ID, $criteria->remove(ClientPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(ClientPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(ClientPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Client) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(ClientPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Client $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(ClientPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(ClientPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(ClientPeer::DATABASE_NAME, ClientPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = ClientPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(ClientPeer::DATABASE_NAME);
$criteria->add(ClientPeer::ID, $pk);
$v = ClientPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(ClientPeer::ID, $pks, Criteria::IN);
$objs = ClientPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseClientPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/ClientMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.ClientMapBuilder');
}

425
lib/model/om/BaseCordinates.php Executable file
View File

@ -0,0 +1,425 @@
<?php
abstract class BaseCordinates extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $client_id;
protected $lat;
protected $lon;
protected $found = 0;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getClientId()
{
return $this->client_id;
}
public function getLat()
{
return $this->lat;
}
public function getLon()
{
return $this->lon;
}
public function getFound()
{
return $this->found;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = CordinatesPeer::ID;
}
}
public function setClientId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->client_id !== $v) {
$this->client_id = $v;
$this->modifiedColumns[] = CordinatesPeer::CLIENT_ID;
}
}
public function setLat($v)
{
if ($this->lat !== $v) {
$this->lat = $v;
$this->modifiedColumns[] = CordinatesPeer::LAT;
}
}
public function setLon($v)
{
if ($this->lon !== $v) {
$this->lon = $v;
$this->modifiedColumns[] = CordinatesPeer::LON;
}
}
public function setFound($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->found !== $v || $v === 0) {
$this->found = $v;
$this->modifiedColumns[] = CordinatesPeer::FOUND;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->client_id = $rs->getInt($startcol + 1);
$this->lat = $rs->getFloat($startcol + 2);
$this->lon = $rs->getFloat($startcol + 3);
$this->found = $rs->getInt($startcol + 4);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating Cordinates object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CordinatesPeer::DATABASE_NAME);
}
try {
$con->begin();
CordinatesPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CordinatesPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = CordinatesPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += CordinatesPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = CordinatesPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CordinatesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getClientId();
break;
case 2:
return $this->getLat();
break;
case 3:
return $this->getLon();
break;
case 4:
return $this->getFound();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CordinatesPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getClientId(),
$keys[2] => $this->getLat(),
$keys[3] => $this->getLon(),
$keys[4] => $this->getFound(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CordinatesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setClientId($value);
break;
case 2:
$this->setLat($value);
break;
case 3:
$this->setLon($value);
break;
case 4:
$this->setFound($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CordinatesPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setClientId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setLat($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setLon($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setFound($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(CordinatesPeer::DATABASE_NAME);
if ($this->isColumnModified(CordinatesPeer::ID)) $criteria->add(CordinatesPeer::ID, $this->id);
if ($this->isColumnModified(CordinatesPeer::CLIENT_ID)) $criteria->add(CordinatesPeer::CLIENT_ID, $this->client_id);
if ($this->isColumnModified(CordinatesPeer::LAT)) $criteria->add(CordinatesPeer::LAT, $this->lat);
if ($this->isColumnModified(CordinatesPeer::LON)) $criteria->add(CordinatesPeer::LON, $this->lon);
if ($this->isColumnModified(CordinatesPeer::FOUND)) $criteria->add(CordinatesPeer::FOUND, $this->found);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(CordinatesPeer::DATABASE_NAME);
$criteria->add(CordinatesPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setClientId($this->client_id);
$copyObj->setLat($this->lat);
$copyObj->setLon($this->lon);
$copyObj->setFound($this->found);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new CordinatesPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,383 @@
<?php
abstract class BaseCordinatesPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'cordinates';
const CLASS_DEFAULT = 'lib.model.Cordinates';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'cordinates.ID';
const CLIENT_ID = 'cordinates.CLIENT_ID';
const LAT = 'cordinates.LAT';
const LON = 'cordinates.LON';
const FOUND = 'cordinates.FOUND';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'ClientId', 'Lat', 'Lon', 'Found', ),
BasePeer::TYPE_COLNAME => array (CordinatesPeer::ID, CordinatesPeer::CLIENT_ID, CordinatesPeer::LAT, CordinatesPeer::LON, CordinatesPeer::FOUND, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'client_id', 'lat', 'lon', 'found', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ClientId' => 1, 'Lat' => 2, 'Lon' => 3, 'Found' => 4, ),
BasePeer::TYPE_COLNAME => array (CordinatesPeer::ID => 0, CordinatesPeer::CLIENT_ID => 1, CordinatesPeer::LAT => 2, CordinatesPeer::LON => 3, CordinatesPeer::FOUND => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'client_id' => 1, 'lat' => 2, 'lon' => 3, 'found' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/CordinatesMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.CordinatesMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = CordinatesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(CordinatesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(CordinatesPeer::ID);
$criteria->addSelectColumn(CordinatesPeer::CLIENT_ID);
$criteria->addSelectColumn(CordinatesPeer::LAT);
$criteria->addSelectColumn(CordinatesPeer::LON);
$criteria->addSelectColumn(CordinatesPeer::FOUND);
}
const COUNT = 'COUNT(cordinates.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT cordinates.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CordinatesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CordinatesPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = CordinatesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CordinatesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return CordinatesPeer::populateObjects(CordinatesPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
CordinatesPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = CordinatesPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return CordinatesPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(CordinatesPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(CordinatesPeer::ID);
$selectCriteria->add(CordinatesPeer::ID, $criteria->remove(CordinatesPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(CordinatesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CordinatesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Cordinates) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CordinatesPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Cordinates $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CordinatesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CordinatesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(CordinatesPeer::DATABASE_NAME, CordinatesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = CordinatesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(CordinatesPeer::DATABASE_NAME);
$criteria->add(CordinatesPeer::ID, $pk);
$v = CordinatesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(CordinatesPeer::ID, $pks, Criteria::IN);
$objs = CordinatesPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseCordinatesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/CordinatesMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.CordinatesMapBuilder');
}

1317
lib/model/om/BaseDevice.php Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,930 @@
<?php
abstract class BaseDeviceCheckup extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $device_id;
protected $client_id;
protected $device_identification;
protected $row_indicator;
protected $device_tech_id;
protected $pass_fail_code;
protected $rec_number;
protected $row_purpose;
protected $physical_inspection;
protected $room;
protected $time;
protected $date;
protected $pass_fail;
protected $aClient;
protected $collDeviceTestDatas;
protected $lastDeviceTestDataCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getDeviceId()
{
return $this->device_id;
}
public function getClientId()
{
return $this->client_id;
}
public function getDeviceIdentification()
{
return $this->device_identification;
}
public function getRowIndicator()
{
return $this->row_indicator;
}
public function getDeviceTechId()
{
return $this->device_tech_id;
}
public function getPassFailCode()
{
return $this->pass_fail_code;
}
public function getRecNumber()
{
return $this->rec_number;
}
public function getRowPurpose()
{
return $this->row_purpose;
}
public function getPhysicalInspection()
{
return $this->physical_inspection;
}
public function getRoom()
{
return $this->room;
}
public function getTime()
{
return $this->time;
}
public function getDate()
{
return $this->date;
}
public function getPassFail()
{
return $this->pass_fail;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::ID;
}
}
public function setDeviceId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->device_id !== $v) {
$this->device_id = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::DEVICE_ID;
}
}
public function setClientId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->client_id !== $v) {
$this->client_id = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::CLIENT_ID;
}
if ($this->aClient !== null && $this->aClient->getId() !== $v) {
$this->aClient = null;
}
}
public function setDeviceIdentification($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->device_identification !== $v) {
$this->device_identification = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::DEVICE_IDENTIFICATION;
}
}
public function setRowIndicator($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->row_indicator !== $v) {
$this->row_indicator = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::ROW_INDICATOR;
}
}
public function setDeviceTechId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->device_tech_id !== $v) {
$this->device_tech_id = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::DEVICE_TECH_ID;
}
}
public function setPassFailCode($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->pass_fail_code !== $v) {
$this->pass_fail_code = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::PASS_FAIL_CODE;
}
}
public function setRecNumber($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->rec_number !== $v) {
$this->rec_number = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::REC_NUMBER;
}
}
public function setRowPurpose($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->row_purpose !== $v) {
$this->row_purpose = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::ROW_PURPOSE;
}
}
public function setPhysicalInspection($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->physical_inspection !== $v) {
$this->physical_inspection = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::PHYSICAL_INSPECTION;
}
}
public function setRoom($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->room !== $v) {
$this->room = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::ROOM;
}
}
public function setTime($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->time !== $v) {
$this->time = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::TIME;
}
}
public function setDate($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->date !== $v) {
$this->date = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::DATE;
}
}
public function setPassFail($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->pass_fail !== $v) {
$this->pass_fail = $v;
$this->modifiedColumns[] = DeviceCheckupPeer::PASS_FAIL;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->device_id = $rs->getInt($startcol + 1);
$this->client_id = $rs->getInt($startcol + 2);
$this->device_identification = $rs->getString($startcol + 3);
$this->row_indicator = $rs->getString($startcol + 4);
$this->device_tech_id = $rs->getString($startcol + 5);
$this->pass_fail_code = $rs->getString($startcol + 6);
$this->rec_number = $rs->getString($startcol + 7);
$this->row_purpose = $rs->getString($startcol + 8);
$this->physical_inspection = $rs->getString($startcol + 9);
$this->room = $rs->getString($startcol + 10);
$this->time = $rs->getString($startcol + 11);
$this->date = $rs->getString($startcol + 12);
$this->pass_fail = $rs->getString($startcol + 13);
$this->resetModified();
$this->setNew(false);
return $startcol + 14;
} catch (Exception $e) {
throw new PropelException("Error populating DeviceCheckup object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DeviceCheckupPeer::DATABASE_NAME);
}
try {
$con->begin();
DeviceCheckupPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DeviceCheckupPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->aClient !== null) {
if ($this->aClient->isModified()) {
$affectedRows += $this->aClient->save($con);
}
$this->setClient($this->aClient);
}
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DeviceCheckupPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DeviceCheckupPeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collDeviceTestDatas !== null) {
foreach($this->collDeviceTestDatas as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if ($this->aClient !== null) {
if (!$this->aClient->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aClient->getValidationFailures());
}
}
if (($retval = DeviceCheckupPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collDeviceTestDatas !== null) {
foreach($this->collDeviceTestDatas as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeviceCheckupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getDeviceId();
break;
case 2:
return $this->getClientId();
break;
case 3:
return $this->getDeviceIdentification();
break;
case 4:
return $this->getRowIndicator();
break;
case 5:
return $this->getDeviceTechId();
break;
case 6:
return $this->getPassFailCode();
break;
case 7:
return $this->getRecNumber();
break;
case 8:
return $this->getRowPurpose();
break;
case 9:
return $this->getPhysicalInspection();
break;
case 10:
return $this->getRoom();
break;
case 11:
return $this->getTime();
break;
case 12:
return $this->getDate();
break;
case 13:
return $this->getPassFail();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeviceCheckupPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getDeviceId(),
$keys[2] => $this->getClientId(),
$keys[3] => $this->getDeviceIdentification(),
$keys[4] => $this->getRowIndicator(),
$keys[5] => $this->getDeviceTechId(),
$keys[6] => $this->getPassFailCode(),
$keys[7] => $this->getRecNumber(),
$keys[8] => $this->getRowPurpose(),
$keys[9] => $this->getPhysicalInspection(),
$keys[10] => $this->getRoom(),
$keys[11] => $this->getTime(),
$keys[12] => $this->getDate(),
$keys[13] => $this->getPassFail(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeviceCheckupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setDeviceId($value);
break;
case 2:
$this->setClientId($value);
break;
case 3:
$this->setDeviceIdentification($value);
break;
case 4:
$this->setRowIndicator($value);
break;
case 5:
$this->setDeviceTechId($value);
break;
case 6:
$this->setPassFailCode($value);
break;
case 7:
$this->setRecNumber($value);
break;
case 8:
$this->setRowPurpose($value);
break;
case 9:
$this->setPhysicalInspection($value);
break;
case 10:
$this->setRoom($value);
break;
case 11:
$this->setTime($value);
break;
case 12:
$this->setDate($value);
break;
case 13:
$this->setPassFail($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeviceCheckupPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDeviceId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setClientId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDeviceIdentification($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setRowIndicator($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDeviceTechId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setPassFailCode($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setRecNumber($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setRowPurpose($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setPhysicalInspection($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setRoom($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setTime($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setDate($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setPassFail($arr[$keys[13]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DeviceCheckupPeer::DATABASE_NAME);
if ($this->isColumnModified(DeviceCheckupPeer::ID)) $criteria->add(DeviceCheckupPeer::ID, $this->id);
if ($this->isColumnModified(DeviceCheckupPeer::DEVICE_ID)) $criteria->add(DeviceCheckupPeer::DEVICE_ID, $this->device_id);
if ($this->isColumnModified(DeviceCheckupPeer::CLIENT_ID)) $criteria->add(DeviceCheckupPeer::CLIENT_ID, $this->client_id);
if ($this->isColumnModified(DeviceCheckupPeer::DEVICE_IDENTIFICATION)) $criteria->add(DeviceCheckupPeer::DEVICE_IDENTIFICATION, $this->device_identification);
if ($this->isColumnModified(DeviceCheckupPeer::ROW_INDICATOR)) $criteria->add(DeviceCheckupPeer::ROW_INDICATOR, $this->row_indicator);
if ($this->isColumnModified(DeviceCheckupPeer::DEVICE_TECH_ID)) $criteria->add(DeviceCheckupPeer::DEVICE_TECH_ID, $this->device_tech_id);
if ($this->isColumnModified(DeviceCheckupPeer::PASS_FAIL_CODE)) $criteria->add(DeviceCheckupPeer::PASS_FAIL_CODE, $this->pass_fail_code);
if ($this->isColumnModified(DeviceCheckupPeer::REC_NUMBER)) $criteria->add(DeviceCheckupPeer::REC_NUMBER, $this->rec_number);
if ($this->isColumnModified(DeviceCheckupPeer::ROW_PURPOSE)) $criteria->add(DeviceCheckupPeer::ROW_PURPOSE, $this->row_purpose);
if ($this->isColumnModified(DeviceCheckupPeer::PHYSICAL_INSPECTION)) $criteria->add(DeviceCheckupPeer::PHYSICAL_INSPECTION, $this->physical_inspection);
if ($this->isColumnModified(DeviceCheckupPeer::ROOM)) $criteria->add(DeviceCheckupPeer::ROOM, $this->room);
if ($this->isColumnModified(DeviceCheckupPeer::TIME)) $criteria->add(DeviceCheckupPeer::TIME, $this->time);
if ($this->isColumnModified(DeviceCheckupPeer::DATE)) $criteria->add(DeviceCheckupPeer::DATE, $this->date);
if ($this->isColumnModified(DeviceCheckupPeer::PASS_FAIL)) $criteria->add(DeviceCheckupPeer::PASS_FAIL, $this->pass_fail);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DeviceCheckupPeer::DATABASE_NAME);
$criteria->add(DeviceCheckupPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDeviceId($this->device_id);
$copyObj->setClientId($this->client_id);
$copyObj->setDeviceIdentification($this->device_identification);
$copyObj->setRowIndicator($this->row_indicator);
$copyObj->setDeviceTechId($this->device_tech_id);
$copyObj->setPassFailCode($this->pass_fail_code);
$copyObj->setRecNumber($this->rec_number);
$copyObj->setRowPurpose($this->row_purpose);
$copyObj->setPhysicalInspection($this->physical_inspection);
$copyObj->setRoom($this->room);
$copyObj->setTime($this->time);
$copyObj->setDate($this->date);
$copyObj->setPassFail($this->pass_fail);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getDeviceTestDatas() as $relObj) {
$copyObj->addDeviceTestData($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DeviceCheckupPeer();
}
return self::$peer;
}
public function setClient($v)
{
if ($v === null) {
$this->setClientId(NULL);
} else {
$this->setClientId($v->getId());
}
$this->aClient = $v;
}
public function getClient($con = null)
{
include_once 'lib/model/om/BaseClientPeer.php';
if ($this->aClient === null && ($this->client_id !== null)) {
$this->aClient = ClientPeer::retrieveByPK($this->client_id, $con);
}
return $this->aClient;
}
public function initDeviceTestDatas()
{
if ($this->collDeviceTestDatas === null) {
$this->collDeviceTestDatas = array();
}
}
public function getDeviceTestDatas($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseDeviceTestDataPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDeviceTestDatas === null) {
if ($this->isNew()) {
$this->collDeviceTestDatas = array();
} else {
$criteria->add(DeviceTestDataPeer::DEVICE_CHECKUP_ID, $this->getId());
DeviceTestDataPeer::addSelectColumns($criteria);
$this->collDeviceTestDatas = DeviceTestDataPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(DeviceTestDataPeer::DEVICE_CHECKUP_ID, $this->getId());
DeviceTestDataPeer::addSelectColumns($criteria);
if (!isset($this->lastDeviceTestDataCriteria) || !$this->lastDeviceTestDataCriteria->equals($criteria)) {
$this->collDeviceTestDatas = DeviceTestDataPeer::doSelect($criteria, $con);
}
}
}
$this->lastDeviceTestDataCriteria = $criteria;
return $this->collDeviceTestDatas;
}
public function countDeviceTestDatas($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseDeviceTestDataPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(DeviceTestDataPeer::DEVICE_CHECKUP_ID, $this->getId());
return DeviceTestDataPeer::doCount($criteria, $distinct, $con);
}
public function addDeviceTestData(DeviceTestData $l)
{
$this->collDeviceTestDatas[] = $l;
$l->setDeviceCheckup($this);
}
}

View File

@ -0,0 +1,589 @@
<?php
abstract class BaseDeviceCheckupPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'device_checkup';
const CLASS_DEFAULT = 'lib.model.DeviceCheckup';
const NUM_COLUMNS = 14;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'device_checkup.ID';
const DEVICE_ID = 'device_checkup.DEVICE_ID';
const CLIENT_ID = 'device_checkup.CLIENT_ID';
const DEVICE_IDENTIFICATION = 'device_checkup.DEVICE_IDENTIFICATION';
const ROW_INDICATOR = 'device_checkup.ROW_INDICATOR';
const DEVICE_TECH_ID = 'device_checkup.DEVICE_TECH_ID';
const PASS_FAIL_CODE = 'device_checkup.PASS_FAIL_CODE';
const REC_NUMBER = 'device_checkup.REC_NUMBER';
const ROW_PURPOSE = 'device_checkup.ROW_PURPOSE';
const PHYSICAL_INSPECTION = 'device_checkup.PHYSICAL_INSPECTION';
const ROOM = 'device_checkup.ROOM';
const TIME = 'device_checkup.TIME';
const DATE = 'device_checkup.DATE';
const PASS_FAIL = 'device_checkup.PASS_FAIL';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'DeviceId', 'ClientId', 'DeviceIdentification', 'RowIndicator', 'DeviceTechId', 'PassFailCode', 'RecNumber', 'RowPurpose', 'PhysicalInspection', 'Room', 'Time', 'Date', 'PassFail', ),
BasePeer::TYPE_COLNAME => array (DeviceCheckupPeer::ID, DeviceCheckupPeer::DEVICE_ID, DeviceCheckupPeer::CLIENT_ID, DeviceCheckupPeer::DEVICE_IDENTIFICATION, DeviceCheckupPeer::ROW_INDICATOR, DeviceCheckupPeer::DEVICE_TECH_ID, DeviceCheckupPeer::PASS_FAIL_CODE, DeviceCheckupPeer::REC_NUMBER, DeviceCheckupPeer::ROW_PURPOSE, DeviceCheckupPeer::PHYSICAL_INSPECTION, DeviceCheckupPeer::ROOM, DeviceCheckupPeer::TIME, DeviceCheckupPeer::DATE, DeviceCheckupPeer::PASS_FAIL, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'device_id', 'client_id', 'device_identification', 'row_indicator', 'device_tech_id', 'pass_fail_code', 'rec_number', 'row_purpose', 'physical_inspection', 'room', 'time', 'date', 'pass_fail', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DeviceId' => 1, 'ClientId' => 2, 'DeviceIdentification' => 3, 'RowIndicator' => 4, 'DeviceTechId' => 5, 'PassFailCode' => 6, 'RecNumber' => 7, 'RowPurpose' => 8, 'PhysicalInspection' => 9, 'Room' => 10, 'Time' => 11, 'Date' => 12, 'PassFail' => 13, ),
BasePeer::TYPE_COLNAME => array (DeviceCheckupPeer::ID => 0, DeviceCheckupPeer::DEVICE_ID => 1, DeviceCheckupPeer::CLIENT_ID => 2, DeviceCheckupPeer::DEVICE_IDENTIFICATION => 3, DeviceCheckupPeer::ROW_INDICATOR => 4, DeviceCheckupPeer::DEVICE_TECH_ID => 5, DeviceCheckupPeer::PASS_FAIL_CODE => 6, DeviceCheckupPeer::REC_NUMBER => 7, DeviceCheckupPeer::ROW_PURPOSE => 8, DeviceCheckupPeer::PHYSICAL_INSPECTION => 9, DeviceCheckupPeer::ROOM => 10, DeviceCheckupPeer::TIME => 11, DeviceCheckupPeer::DATE => 12, DeviceCheckupPeer::PASS_FAIL => 13, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'device_id' => 1, 'client_id' => 2, 'device_identification' => 3, 'row_indicator' => 4, 'device_tech_id' => 5, 'pass_fail_code' => 6, 'rec_number' => 7, 'row_purpose' => 8, 'physical_inspection' => 9, 'room' => 10, 'time' => 11, 'date' => 12, 'pass_fail' => 13, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DeviceCheckupMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DeviceCheckupMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DeviceCheckupPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DeviceCheckupPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DeviceCheckupPeer::ID);
$criteria->addSelectColumn(DeviceCheckupPeer::DEVICE_ID);
$criteria->addSelectColumn(DeviceCheckupPeer::CLIENT_ID);
$criteria->addSelectColumn(DeviceCheckupPeer::DEVICE_IDENTIFICATION);
$criteria->addSelectColumn(DeviceCheckupPeer::ROW_INDICATOR);
$criteria->addSelectColumn(DeviceCheckupPeer::DEVICE_TECH_ID);
$criteria->addSelectColumn(DeviceCheckupPeer::PASS_FAIL_CODE);
$criteria->addSelectColumn(DeviceCheckupPeer::REC_NUMBER);
$criteria->addSelectColumn(DeviceCheckupPeer::ROW_PURPOSE);
$criteria->addSelectColumn(DeviceCheckupPeer::PHYSICAL_INSPECTION);
$criteria->addSelectColumn(DeviceCheckupPeer::ROOM);
$criteria->addSelectColumn(DeviceCheckupPeer::TIME);
$criteria->addSelectColumn(DeviceCheckupPeer::DATE);
$criteria->addSelectColumn(DeviceCheckupPeer::PASS_FAIL);
}
const COUNT = 'COUNT(device_checkup.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT device_checkup.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DeviceCheckupPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DeviceCheckupPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DeviceCheckupPeer::populateObjects(DeviceCheckupPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DeviceCheckupPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DeviceCheckupPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinClient(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeviceCheckupPeer::CLIENT_ID, ClientPeer::ID);
$rs = DeviceCheckupPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinClient(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeviceCheckupPeer::addSelectColumns($c);
$startcol = (DeviceCheckupPeer::NUM_COLUMNS - DeviceCheckupPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
ClientPeer::addSelectColumns($c);
$c->addJoin(DeviceCheckupPeer::CLIENT_ID, ClientPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DeviceCheckupPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getClient(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeviceCheckup($obj1); break;
}
}
if ($newObject) {
$obj2->initDeviceCheckups();
$obj2->addDeviceCheckup($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceCheckupPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeviceCheckupPeer::CLIENT_ID, ClientPeer::ID);
$rs = DeviceCheckupPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeviceCheckupPeer::addSelectColumns($c);
$startcol2 = (DeviceCheckupPeer::NUM_COLUMNS - DeviceCheckupPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
ClientPeer::addSelectColumns($c);
$startcol3 = $startcol2 + ClientPeer::NUM_COLUMNS;
$c->addJoin(DeviceCheckupPeer::CLIENT_ID, ClientPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DeviceCheckupPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getClient(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeviceCheckup($obj1); break;
}
}
if ($newObject) {
$obj2->initDeviceCheckups();
$obj2->addDeviceCheckup($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DeviceCheckupPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DeviceCheckupPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DeviceCheckupPeer::ID);
$selectCriteria->add(DeviceCheckupPeer::ID, $criteria->remove(DeviceCheckupPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DeviceCheckupPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DeviceCheckupPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof DeviceCheckup) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DeviceCheckupPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(DeviceCheckup $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DeviceCheckupPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DeviceCheckupPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DeviceCheckupPeer::DATABASE_NAME, DeviceCheckupPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DeviceCheckupPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DeviceCheckupPeer::DATABASE_NAME);
$criteria->add(DeviceCheckupPeer::ID, $pk);
$v = DeviceCheckupPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DeviceCheckupPeer::ID, $pks, Criteria::IN);
$objs = DeviceCheckupPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDeviceCheckupPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DeviceCheckupMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DeviceCheckupMapBuilder');
}

854
lib/model/om/BaseDevicePeer.php Executable file
View File

@ -0,0 +1,854 @@
<?php
abstract class BaseDevicePeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'device';
const CLASS_DEFAULT = 'lib.model.Device';
const NUM_COLUMNS = 12;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'device.ID';
const SPECIFICATION_ID = 'device.SPECIFICATION_ID';
const CLIENT_ID = 'device.CLIENT_ID';
const SERIAL_NUMBER = 'device.SERIAL_NUMBER';
const LOCATION = 'device.LOCATION';
const FREQUENCY = 'device.FREQUENCY';
const STATUS = 'device.STATUS';
const IDENTIFICATION = 'device.IDENTIFICATION';
const CREATED_AT = 'device.CREATED_AT';
const UPDATED_AT = 'device.UPDATED_AT';
const COMMENTS = 'device.COMMENTS';
const LAST_PM_DATE = 'device.LAST_PM_DATE';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'SpecificationId', 'ClientId', 'SerialNumber', 'Location', 'Frequency', 'Status', 'Identification', 'CreatedAt', 'UpdatedAt', 'Comments', 'LastPmDate', ),
BasePeer::TYPE_COLNAME => array (DevicePeer::ID, DevicePeer::SPECIFICATION_ID, DevicePeer::CLIENT_ID, DevicePeer::SERIAL_NUMBER, DevicePeer::LOCATION, DevicePeer::FREQUENCY, DevicePeer::STATUS, DevicePeer::IDENTIFICATION, DevicePeer::CREATED_AT, DevicePeer::UPDATED_AT, DevicePeer::COMMENTS, DevicePeer::LAST_PM_DATE, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'specification_id', 'client_id', 'serial_number', 'location', 'frequency', 'status', 'identification', 'created_at', 'updated_at', 'comments', 'last_pm_date', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'SpecificationId' => 1, 'ClientId' => 2, 'SerialNumber' => 3, 'Location' => 4, 'Frequency' => 5, 'Status' => 6, 'Identification' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, 'Comments' => 10, 'LastPmDate' => 11, ),
BasePeer::TYPE_COLNAME => array (DevicePeer::ID => 0, DevicePeer::SPECIFICATION_ID => 1, DevicePeer::CLIENT_ID => 2, DevicePeer::SERIAL_NUMBER => 3, DevicePeer::LOCATION => 4, DevicePeer::FREQUENCY => 5, DevicePeer::STATUS => 6, DevicePeer::IDENTIFICATION => 7, DevicePeer::CREATED_AT => 8, DevicePeer::UPDATED_AT => 9, DevicePeer::COMMENTS => 10, DevicePeer::LAST_PM_DATE => 11, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'specification_id' => 1, 'client_id' => 2, 'serial_number' => 3, 'location' => 4, 'frequency' => 5, 'status' => 6, 'identification' => 7, 'created_at' => 8, 'updated_at' => 9, 'comments' => 10, 'last_pm_date' => 11, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DeviceMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DeviceMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DevicePeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DevicePeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DevicePeer::ID);
$criteria->addSelectColumn(DevicePeer::SPECIFICATION_ID);
$criteria->addSelectColumn(DevicePeer::CLIENT_ID);
$criteria->addSelectColumn(DevicePeer::SERIAL_NUMBER);
$criteria->addSelectColumn(DevicePeer::LOCATION);
$criteria->addSelectColumn(DevicePeer::FREQUENCY);
$criteria->addSelectColumn(DevicePeer::STATUS);
$criteria->addSelectColumn(DevicePeer::IDENTIFICATION);
$criteria->addSelectColumn(DevicePeer::CREATED_AT);
$criteria->addSelectColumn(DevicePeer::UPDATED_AT);
$criteria->addSelectColumn(DevicePeer::COMMENTS);
$criteria->addSelectColumn(DevicePeer::LAST_PM_DATE);
}
const COUNT = 'COUNT(device.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT device.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DevicePeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DevicePeer::populateObjects(DevicePeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DevicePeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DevicePeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinSpecification(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doCountJoinClient(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinSpecification(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicePeer::addSelectColumns($c);
$startcol = (DevicePeer::NUM_COLUMNS - DevicePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
SpecificationPeer::addSelectColumns($c);
$c->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = SpecificationPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getSpecification(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevice($obj1); break;
}
}
if ($newObject) {
$obj2->initDevices();
$obj2->addDevice($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doSelectJoinClient(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicePeer::addSelectColumns($c);
$startcol = (DevicePeer::NUM_COLUMNS - DevicePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
ClientPeer::addSelectColumns($c);
$c->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getClient(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevice($obj1); break;
}
}
if ($newObject) {
$obj2->initDevices();
$obj2->addDevice($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$criteria->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicePeer::addSelectColumns($c);
$startcol2 = (DevicePeer::NUM_COLUMNS - DevicePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
SpecificationPeer::addSelectColumns($c);
$startcol3 = $startcol2 + SpecificationPeer::NUM_COLUMNS;
ClientPeer::addSelectColumns($c);
$startcol4 = $startcol3 + ClientPeer::NUM_COLUMNS;
$c->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$c->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = SpecificationPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getSpecification(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevice($obj1); break;
}
}
if ($newObject) {
$obj2->initDevices();
$obj2->addDevice($obj1);
}
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj3 = new $cls();
$obj3->hydrate($rs, $startcol3);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj3 = $temp_obj1->getClient(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
$newObject = false;
$temp_obj3->addDevice($obj1); break;
}
}
if ($newObject) {
$obj3->initDevices();
$obj3->addDevice($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAllExceptSpecification(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doCountJoinAllExceptClient(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$rs = DevicePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAllExceptSpecification(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicePeer::addSelectColumns($c);
$startcol2 = (DevicePeer::NUM_COLUMNS - DevicePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
ClientPeer::addSelectColumns($c);
$startcol3 = $startcol2 + ClientPeer::NUM_COLUMNS;
$c->addJoin(DevicePeer::CLIENT_ID, ClientPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = ClientPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getClient(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevice($obj1);
break;
}
}
if ($newObject) {
$obj2->initDevices();
$obj2->addDevice($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function doSelectJoinAllExceptClient(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicePeer::addSelectColumns($c);
$startcol2 = (DevicePeer::NUM_COLUMNS - DevicePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
SpecificationPeer::addSelectColumns($c);
$startcol3 = $startcol2 + SpecificationPeer::NUM_COLUMNS;
$c->addJoin(DevicePeer::SPECIFICATION_ID, SpecificationPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = SpecificationPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getSpecification(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevice($obj1);
break;
}
}
if ($newObject) {
$obj2->initDevices();
$obj2->addDevice($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DevicePeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DevicePeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DevicePeer::ID);
$selectCriteria->add(DevicePeer::ID, $criteria->remove(DevicePeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DevicePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DevicePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Device) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DevicePeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Device $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DevicePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DevicePeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DevicePeer::DATABASE_NAME, DevicePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DevicePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DevicePeer::DATABASE_NAME);
$criteria->add(DevicePeer::ID, $pk);
$v = DevicePeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DevicePeer::ID, $pks, Criteria::IN);
$objs = DevicePeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDevicePeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DeviceMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DeviceMapBuilder');
}

View File

@ -0,0 +1,563 @@
<?php
abstract class BaseDeviceTestData extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $device_checkup_id;
protected $name;
protected $type;
protected $value;
protected $passfail;
protected $unit;
protected $aDeviceCheckup;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getDeviceCheckupId()
{
return $this->device_checkup_id;
}
public function getName()
{
return $this->name;
}
public function getType()
{
return $this->type;
}
public function getValue()
{
return $this->value;
}
public function getPassfail()
{
return $this->passfail;
}
public function getUnit()
{
return $this->unit;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::ID;
}
}
public function setDeviceCheckupId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->device_checkup_id !== $v) {
$this->device_checkup_id = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::DEVICE_CHECKUP_ID;
}
if ($this->aDeviceCheckup !== null && $this->aDeviceCheckup->getId() !== $v) {
$this->aDeviceCheckup = null;
}
}
public function setName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::NAME;
}
}
public function setType($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->type !== $v) {
$this->type = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::TYPE;
}
}
public function setValue($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->value !== $v) {
$this->value = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::VALUE;
}
}
public function setPassfail($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->passfail !== $v) {
$this->passfail = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::PASSFAIL;
}
}
public function setUnit($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->unit !== $v) {
$this->unit = $v;
$this->modifiedColumns[] = DeviceTestDataPeer::UNIT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->device_checkup_id = $rs->getInt($startcol + 1);
$this->name = $rs->getString($startcol + 2);
$this->type = $rs->getString($startcol + 3);
$this->value = $rs->getString($startcol + 4);
$this->passfail = $rs->getString($startcol + 5);
$this->unit = $rs->getString($startcol + 6);
$this->resetModified();
$this->setNew(false);
return $startcol + 7;
} catch (Exception $e) {
throw new PropelException("Error populating DeviceTestData object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DeviceTestDataPeer::DATABASE_NAME);
}
try {
$con->begin();
DeviceTestDataPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DeviceTestDataPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->aDeviceCheckup !== null) {
if ($this->aDeviceCheckup->isModified()) {
$affectedRows += $this->aDeviceCheckup->save($con);
}
$this->setDeviceCheckup($this->aDeviceCheckup);
}
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DeviceTestDataPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DeviceTestDataPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if ($this->aDeviceCheckup !== null) {
if (!$this->aDeviceCheckup->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aDeviceCheckup->getValidationFailures());
}
}
if (($retval = DeviceTestDataPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeviceTestDataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getDeviceCheckupId();
break;
case 2:
return $this->getName();
break;
case 3:
return $this->getType();
break;
case 4:
return $this->getValue();
break;
case 5:
return $this->getPassfail();
break;
case 6:
return $this->getUnit();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeviceTestDataPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getDeviceCheckupId(),
$keys[2] => $this->getName(),
$keys[3] => $this->getType(),
$keys[4] => $this->getValue(),
$keys[5] => $this->getPassfail(),
$keys[6] => $this->getUnit(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeviceTestDataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setDeviceCheckupId($value);
break;
case 2:
$this->setName($value);
break;
case 3:
$this->setType($value);
break;
case 4:
$this->setValue($value);
break;
case 5:
$this->setPassfail($value);
break;
case 6:
$this->setUnit($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeviceTestDataPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDeviceCheckupId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setType($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPassfail($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setUnit($arr[$keys[6]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DeviceTestDataPeer::DATABASE_NAME);
if ($this->isColumnModified(DeviceTestDataPeer::ID)) $criteria->add(DeviceTestDataPeer::ID, $this->id);
if ($this->isColumnModified(DeviceTestDataPeer::DEVICE_CHECKUP_ID)) $criteria->add(DeviceTestDataPeer::DEVICE_CHECKUP_ID, $this->device_checkup_id);
if ($this->isColumnModified(DeviceTestDataPeer::NAME)) $criteria->add(DeviceTestDataPeer::NAME, $this->name);
if ($this->isColumnModified(DeviceTestDataPeer::TYPE)) $criteria->add(DeviceTestDataPeer::TYPE, $this->type);
if ($this->isColumnModified(DeviceTestDataPeer::VALUE)) $criteria->add(DeviceTestDataPeer::VALUE, $this->value);
if ($this->isColumnModified(DeviceTestDataPeer::PASSFAIL)) $criteria->add(DeviceTestDataPeer::PASSFAIL, $this->passfail);
if ($this->isColumnModified(DeviceTestDataPeer::UNIT)) $criteria->add(DeviceTestDataPeer::UNIT, $this->unit);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DeviceTestDataPeer::DATABASE_NAME);
$criteria->add(DeviceTestDataPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDeviceCheckupId($this->device_checkup_id);
$copyObj->setName($this->name);
$copyObj->setType($this->type);
$copyObj->setValue($this->value);
$copyObj->setPassfail($this->passfail);
$copyObj->setUnit($this->unit);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DeviceTestDataPeer();
}
return self::$peer;
}
public function setDeviceCheckup($v)
{
if ($v === null) {
$this->setDeviceCheckupId(NULL);
} else {
$this->setDeviceCheckupId($v->getId());
}
$this->aDeviceCheckup = $v;
}
public function getDeviceCheckup($con = null)
{
include_once 'lib/model/om/BaseDeviceCheckupPeer.php';
if ($this->aDeviceCheckup === null && ($this->device_checkup_id !== null)) {
$this->aDeviceCheckup = DeviceCheckupPeer::retrieveByPK($this->device_checkup_id, $con);
}
return $this->aDeviceCheckup;
}
}

View File

@ -0,0 +1,554 @@
<?php
abstract class BaseDeviceTestDataPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'device_test_data';
const CLASS_DEFAULT = 'lib.model.DeviceTestData';
const NUM_COLUMNS = 7;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'device_test_data.ID';
const DEVICE_CHECKUP_ID = 'device_test_data.DEVICE_CHECKUP_ID';
const NAME = 'device_test_data.NAME';
const TYPE = 'device_test_data.TYPE';
const VALUE = 'device_test_data.VALUE';
const PASSFAIL = 'device_test_data.PASSFAIL';
const UNIT = 'device_test_data.UNIT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'DeviceCheckupId', 'Name', 'Type', 'Value', 'Passfail', 'Unit', ),
BasePeer::TYPE_COLNAME => array (DeviceTestDataPeer::ID, DeviceTestDataPeer::DEVICE_CHECKUP_ID, DeviceTestDataPeer::NAME, DeviceTestDataPeer::TYPE, DeviceTestDataPeer::VALUE, DeviceTestDataPeer::PASSFAIL, DeviceTestDataPeer::UNIT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'device_checkup_id', 'name', 'type', 'value', 'passFail', 'unit', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DeviceCheckupId' => 1, 'Name' => 2, 'Type' => 3, 'Value' => 4, 'Passfail' => 5, 'Unit' => 6, ),
BasePeer::TYPE_COLNAME => array (DeviceTestDataPeer::ID => 0, DeviceTestDataPeer::DEVICE_CHECKUP_ID => 1, DeviceTestDataPeer::NAME => 2, DeviceTestDataPeer::TYPE => 3, DeviceTestDataPeer::VALUE => 4, DeviceTestDataPeer::PASSFAIL => 5, DeviceTestDataPeer::UNIT => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'device_checkup_id' => 1, 'name' => 2, 'type' => 3, 'value' => 4, 'passFail' => 5, 'unit' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DeviceTestDataMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DeviceTestDataMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DeviceTestDataPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DeviceTestDataPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DeviceTestDataPeer::ID);
$criteria->addSelectColumn(DeviceTestDataPeer::DEVICE_CHECKUP_ID);
$criteria->addSelectColumn(DeviceTestDataPeer::NAME);
$criteria->addSelectColumn(DeviceTestDataPeer::TYPE);
$criteria->addSelectColumn(DeviceTestDataPeer::VALUE);
$criteria->addSelectColumn(DeviceTestDataPeer::PASSFAIL);
$criteria->addSelectColumn(DeviceTestDataPeer::UNIT);
}
const COUNT = 'COUNT(device_test_data.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT device_test_data.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DeviceTestDataPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DeviceTestDataPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DeviceTestDataPeer::populateObjects(DeviceTestDataPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DeviceTestDataPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DeviceTestDataPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinDeviceCheckup(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeviceTestDataPeer::DEVICE_CHECKUP_ID, DeviceCheckupPeer::ID);
$rs = DeviceTestDataPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinDeviceCheckup(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeviceTestDataPeer::addSelectColumns($c);
$startcol = (DeviceTestDataPeer::NUM_COLUMNS - DeviceTestDataPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DeviceCheckupPeer::addSelectColumns($c);
$c->addJoin(DeviceTestDataPeer::DEVICE_CHECKUP_ID, DeviceCheckupPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DeviceTestDataPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DeviceCheckupPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getDeviceCheckup(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeviceTestData($obj1); break;
}
}
if ($newObject) {
$obj2->initDeviceTestDatas();
$obj2->addDeviceTestData($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeviceTestDataPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeviceTestDataPeer::DEVICE_CHECKUP_ID, DeviceCheckupPeer::ID);
$rs = DeviceTestDataPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeviceTestDataPeer::addSelectColumns($c);
$startcol2 = (DeviceTestDataPeer::NUM_COLUMNS - DeviceTestDataPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DeviceCheckupPeer::addSelectColumns($c);
$startcol3 = $startcol2 + DeviceCheckupPeer::NUM_COLUMNS;
$c->addJoin(DeviceTestDataPeer::DEVICE_CHECKUP_ID, DeviceCheckupPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DeviceTestDataPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DeviceCheckupPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getDeviceCheckup(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeviceTestData($obj1); break;
}
}
if ($newObject) {
$obj2->initDeviceTestDatas();
$obj2->addDeviceTestData($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DeviceTestDataPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DeviceTestDataPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DeviceTestDataPeer::ID);
$selectCriteria->add(DeviceTestDataPeer::ID, $criteria->remove(DeviceTestDataPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DeviceTestDataPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DeviceTestDataPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof DeviceTestData) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DeviceTestDataPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(DeviceTestData $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DeviceTestDataPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DeviceTestDataPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DeviceTestDataPeer::DATABASE_NAME, DeviceTestDataPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DeviceTestDataPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DeviceTestDataPeer::DATABASE_NAME);
$criteria->add(DeviceTestDataPeer::ID, $pk);
$v = DeviceTestDataPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DeviceTestDataPeer::ID, $pks, Criteria::IN);
$objs = DeviceTestDataPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDeviceTestDataPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DeviceTestDataMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DeviceTestDataMapBuilder');
}

View File

@ -0,0 +1,487 @@
<?php
abstract class BaseDevicesFailed extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $device_id;
protected $report_id;
protected $client_id;
protected $status;
protected $aDevice;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getDeviceId()
{
return $this->device_id;
}
public function getReportId()
{
return $this->report_id;
}
public function getClientId()
{
return $this->client_id;
}
public function getStatus()
{
return $this->status;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DevicesFailedPeer::ID;
}
}
public function setDeviceId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->device_id !== $v) {
$this->device_id = $v;
$this->modifiedColumns[] = DevicesFailedPeer::DEVICE_ID;
}
if ($this->aDevice !== null && $this->aDevice->getId() !== $v) {
$this->aDevice = null;
}
}
public function setReportId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->report_id !== $v) {
$this->report_id = $v;
$this->modifiedColumns[] = DevicesFailedPeer::REPORT_ID;
}
}
public function setClientId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->client_id !== $v) {
$this->client_id = $v;
$this->modifiedColumns[] = DevicesFailedPeer::CLIENT_ID;
}
}
public function setStatus($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->status !== $v) {
$this->status = $v;
$this->modifiedColumns[] = DevicesFailedPeer::STATUS;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->device_id = $rs->getInt($startcol + 1);
$this->report_id = $rs->getInt($startcol + 2);
$this->client_id = $rs->getString($startcol + 3);
$this->status = $rs->getString($startcol + 4);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating DevicesFailed object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DevicesFailedPeer::DATABASE_NAME);
}
try {
$con->begin();
DevicesFailedPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DevicesFailedPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->aDevice !== null) {
if ($this->aDevice->isModified()) {
$affectedRows += $this->aDevice->save($con);
}
$this->setDevice($this->aDevice);
}
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DevicesFailedPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DevicesFailedPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if ($this->aDevice !== null) {
if (!$this->aDevice->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aDevice->getValidationFailures());
}
}
if (($retval = DevicesFailedPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DevicesFailedPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getDeviceId();
break;
case 2:
return $this->getReportId();
break;
case 3:
return $this->getClientId();
break;
case 4:
return $this->getStatus();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DevicesFailedPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getDeviceId(),
$keys[2] => $this->getReportId(),
$keys[3] => $this->getClientId(),
$keys[4] => $this->getStatus(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DevicesFailedPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setDeviceId($value);
break;
case 2:
$this->setReportId($value);
break;
case 3:
$this->setClientId($value);
break;
case 4:
$this->setStatus($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DevicesFailedPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDeviceId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setReportId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setClientId($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setStatus($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DevicesFailedPeer::DATABASE_NAME);
if ($this->isColumnModified(DevicesFailedPeer::ID)) $criteria->add(DevicesFailedPeer::ID, $this->id);
if ($this->isColumnModified(DevicesFailedPeer::DEVICE_ID)) $criteria->add(DevicesFailedPeer::DEVICE_ID, $this->device_id);
if ($this->isColumnModified(DevicesFailedPeer::REPORT_ID)) $criteria->add(DevicesFailedPeer::REPORT_ID, $this->report_id);
if ($this->isColumnModified(DevicesFailedPeer::CLIENT_ID)) $criteria->add(DevicesFailedPeer::CLIENT_ID, $this->client_id);
if ($this->isColumnModified(DevicesFailedPeer::STATUS)) $criteria->add(DevicesFailedPeer::STATUS, $this->status);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DevicesFailedPeer::DATABASE_NAME);
$criteria->add(DevicesFailedPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDeviceId($this->device_id);
$copyObj->setReportId($this->report_id);
$copyObj->setClientId($this->client_id);
$copyObj->setStatus($this->status);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DevicesFailedPeer();
}
return self::$peer;
}
public function setDevice($v)
{
if ($v === null) {
$this->setDeviceId(NULL);
} else {
$this->setDeviceId($v->getId());
}
$this->aDevice = $v;
}
public function getDevice($con = null)
{
include_once 'lib/model/om/BaseDevicePeer.php';
if ($this->aDevice === null && ($this->device_id !== null)) {
$this->aDevice = DevicePeer::retrieveByPK($this->device_id, $con);
}
return $this->aDevice;
}
}

View File

@ -0,0 +1,544 @@
<?php
abstract class BaseDevicesFailedPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'devices_failed';
const CLASS_DEFAULT = 'lib.model.DevicesFailed';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'devices_failed.ID';
const DEVICE_ID = 'devices_failed.DEVICE_ID';
const REPORT_ID = 'devices_failed.REPORT_ID';
const CLIENT_ID = 'devices_failed.CLIENT_ID';
const STATUS = 'devices_failed.STATUS';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'DeviceId', 'ReportId', 'ClientId', 'Status', ),
BasePeer::TYPE_COLNAME => array (DevicesFailedPeer::ID, DevicesFailedPeer::DEVICE_ID, DevicesFailedPeer::REPORT_ID, DevicesFailedPeer::CLIENT_ID, DevicesFailedPeer::STATUS, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'device_id', 'report_id', 'client_id', 'status', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DeviceId' => 1, 'ReportId' => 2, 'ClientId' => 3, 'Status' => 4, ),
BasePeer::TYPE_COLNAME => array (DevicesFailedPeer::ID => 0, DevicesFailedPeer::DEVICE_ID => 1, DevicesFailedPeer::REPORT_ID => 2, DevicesFailedPeer::CLIENT_ID => 3, DevicesFailedPeer::STATUS => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'device_id' => 1, 'report_id' => 2, 'client_id' => 3, 'status' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DevicesFailedMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DevicesFailedMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DevicesFailedPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DevicesFailedPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DevicesFailedPeer::ID);
$criteria->addSelectColumn(DevicesFailedPeer::DEVICE_ID);
$criteria->addSelectColumn(DevicesFailedPeer::REPORT_ID);
$criteria->addSelectColumn(DevicesFailedPeer::CLIENT_ID);
$criteria->addSelectColumn(DevicesFailedPeer::STATUS);
}
const COUNT = 'COUNT(devices_failed.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT devices_failed.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DevicesFailedPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DevicesFailedPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DevicesFailedPeer::populateObjects(DevicesFailedPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DevicesFailedPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DevicesFailedPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinDevice(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicesFailedPeer::DEVICE_ID, DevicePeer::ID);
$rs = DevicesFailedPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinDevice(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicesFailedPeer::addSelectColumns($c);
$startcol = (DevicesFailedPeer::NUM_COLUMNS - DevicesFailedPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DevicePeer::addSelectColumns($c);
$c->addJoin(DevicesFailedPeer::DEVICE_ID, DevicePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicesFailedPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getDevice(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevicesFailed($obj1); break;
}
}
if ($newObject) {
$obj2->initDevicesFaileds();
$obj2->addDevicesFailed($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicesFailedPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DevicesFailedPeer::DEVICE_ID, DevicePeer::ID);
$rs = DevicesFailedPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DevicesFailedPeer::addSelectColumns($c);
$startcol2 = (DevicesFailedPeer::NUM_COLUMNS - DevicesFailedPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DevicePeer::addSelectColumns($c);
$startcol3 = $startcol2 + DevicePeer::NUM_COLUMNS;
$c->addJoin(DevicesFailedPeer::DEVICE_ID, DevicePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = DevicesFailedPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getDevice(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDevicesFailed($obj1); break;
}
}
if ($newObject) {
$obj2->initDevicesFaileds();
$obj2->addDevicesFailed($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DevicesFailedPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DevicesFailedPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DevicesFailedPeer::ID);
$selectCriteria->add(DevicesFailedPeer::ID, $criteria->remove(DevicesFailedPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DevicesFailedPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DevicesFailedPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof DevicesFailed) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DevicesFailedPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(DevicesFailed $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DevicesFailedPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DevicesFailedPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DevicesFailedPeer::DATABASE_NAME, DevicesFailedPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DevicesFailedPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DevicesFailedPeer::DATABASE_NAME);
$criteria->add(DevicesFailedPeer::ID, $pk);
$v = DevicesFailedPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DevicesFailedPeer::ID, $pks, Criteria::IN);
$objs = DevicesFailedPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDevicesFailedPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DevicesFailedMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DevicesFailedMapBuilder');
}

441
lib/model/om/BaseDevicesFiles.php Executable file
View File

@ -0,0 +1,441 @@
<?php
abstract class BaseDevicesFiles extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $filename;
protected $created_at;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getFilename()
{
return $this->filename;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DevicesFilesPeer::ID;
}
}
public function setFilename($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->filename !== $v) {
$this->filename = $v;
$this->modifiedColumns[] = DevicesFilesPeer::FILENAME;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = DevicesFilesPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = DevicesFilesPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->filename = $rs->getString($startcol + 1);
$this->created_at = $rs->getTimestamp($startcol + 2, null);
$this->updated_at = $rs->getTimestamp($startcol + 3, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 4;
} catch (Exception $e) {
throw new PropelException("Error populating DevicesFiles object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DevicesFilesPeer::DATABASE_NAME);
}
try {
$con->begin();
DevicesFilesPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(DevicesFilesPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(DevicesFilesPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DevicesFilesPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DevicesFilesPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DevicesFilesPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = DevicesFilesPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DevicesFilesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getFilename();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DevicesFilesPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getFilename(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DevicesFilesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setFilename($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DevicesFilesPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setFilename($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DevicesFilesPeer::DATABASE_NAME);
if ($this->isColumnModified(DevicesFilesPeer::ID)) $criteria->add(DevicesFilesPeer::ID, $this->id);
if ($this->isColumnModified(DevicesFilesPeer::FILENAME)) $criteria->add(DevicesFilesPeer::FILENAME, $this->filename);
if ($this->isColumnModified(DevicesFilesPeer::CREATED_AT)) $criteria->add(DevicesFilesPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(DevicesFilesPeer::UPDATED_AT)) $criteria->add(DevicesFilesPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DevicesFilesPeer::DATABASE_NAME);
$criteria->add(DevicesFilesPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setFilename($this->filename);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DevicesFilesPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,378 @@
<?php
abstract class BaseDevicesFilesPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'devices_files';
const CLASS_DEFAULT = 'lib.model.DevicesFiles';
const NUM_COLUMNS = 4;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'devices_files.ID';
const FILENAME = 'devices_files.FILENAME';
const CREATED_AT = 'devices_files.CREATED_AT';
const UPDATED_AT = 'devices_files.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Filename', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (DevicesFilesPeer::ID, DevicesFilesPeer::FILENAME, DevicesFilesPeer::CREATED_AT, DevicesFilesPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'filename', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Filename' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
BasePeer::TYPE_COLNAME => array (DevicesFilesPeer::ID => 0, DevicesFilesPeer::FILENAME => 1, DevicesFilesPeer::CREATED_AT => 2, DevicesFilesPeer::UPDATED_AT => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'filename' => 1, 'created_at' => 2, 'updated_at' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DevicesFilesMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DevicesFilesMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DevicesFilesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DevicesFilesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DevicesFilesPeer::ID);
$criteria->addSelectColumn(DevicesFilesPeer::FILENAME);
$criteria->addSelectColumn(DevicesFilesPeer::CREATED_AT);
$criteria->addSelectColumn(DevicesFilesPeer::UPDATED_AT);
}
const COUNT = 'COUNT(devices_files.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT devices_files.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DevicesFilesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DevicesFilesPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DevicesFilesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DevicesFilesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DevicesFilesPeer::populateObjects(DevicesFilesPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DevicesFilesPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DevicesFilesPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DevicesFilesPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DevicesFilesPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DevicesFilesPeer::ID);
$selectCriteria->add(DevicesFilesPeer::ID, $criteria->remove(DevicesFilesPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DevicesFilesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DevicesFilesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof DevicesFiles) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DevicesFilesPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(DevicesFiles $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DevicesFilesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DevicesFilesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DevicesFilesPeer::DATABASE_NAME, DevicesFilesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DevicesFilesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DevicesFilesPeer::DATABASE_NAME);
$criteria->add(DevicesFilesPeer::ID, $pk);
$v = DevicesFilesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DevicesFilesPeer::ID, $pks, Criteria::IN);
$objs = DevicesFilesPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDevicesFilesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DevicesFilesMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DevicesFilesMapBuilder');
}

532
lib/model/om/BaseDistances.php Executable file
View File

@ -0,0 +1,532 @@
<?php
abstract class BaseDistances extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $client_id_1;
protected $client_id_2;
protected $travel_time_hours;
protected $travel_time_mins;
protected $travel_distance;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getClientId1()
{
return $this->client_id_1;
}
public function getClientId2()
{
return $this->client_id_2;
}
public function getTravelTimeHours()
{
return $this->travel_time_hours;
}
public function getTravelTimeMins()
{
return $this->travel_time_mins;
}
public function getTravelDistance()
{
return $this->travel_distance;
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DistancesPeer::ID;
}
}
public function setClientId1($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->client_id_1 !== $v) {
$this->client_id_1 = $v;
$this->modifiedColumns[] = DistancesPeer::CLIENT_ID_1;
}
}
public function setClientId2($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->client_id_2 !== $v) {
$this->client_id_2 = $v;
$this->modifiedColumns[] = DistancesPeer::CLIENT_ID_2;
}
}
public function setTravelTimeHours($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->travel_time_hours !== $v) {
$this->travel_time_hours = $v;
$this->modifiedColumns[] = DistancesPeer::TRAVEL_TIME_HOURS;
}
}
public function setTravelTimeMins($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->travel_time_mins !== $v) {
$this->travel_time_mins = $v;
$this->modifiedColumns[] = DistancesPeer::TRAVEL_TIME_MINS;
}
}
public function setTravelDistance($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->travel_distance !== $v) {
$this->travel_distance = $v;
$this->modifiedColumns[] = DistancesPeer::TRAVEL_DISTANCE;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = DistancesPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->client_id_1 = $rs->getInt($startcol + 1);
$this->client_id_2 = $rs->getInt($startcol + 2);
$this->travel_time_hours = $rs->getInt($startcol + 3);
$this->travel_time_mins = $rs->getInt($startcol + 4);
$this->travel_distance = $rs->getInt($startcol + 5);
$this->updated_at = $rs->getTimestamp($startcol + 6, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 7;
} catch (Exception $e) {
throw new PropelException("Error populating Distances object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DistancesPeer::DATABASE_NAME);
}
try {
$con->begin();
DistancesPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isModified() && !$this->isColumnModified(DistancesPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DistancesPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DistancesPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DistancesPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = DistancesPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DistancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getClientId1();
break;
case 2:
return $this->getClientId2();
break;
case 3:
return $this->getTravelTimeHours();
break;
case 4:
return $this->getTravelTimeMins();
break;
case 5:
return $this->getTravelDistance();
break;
case 6:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DistancesPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getClientId1(),
$keys[2] => $this->getClientId2(),
$keys[3] => $this->getTravelTimeHours(),
$keys[4] => $this->getTravelTimeMins(),
$keys[5] => $this->getTravelDistance(),
$keys[6] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DistancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setClientId1($value);
break;
case 2:
$this->setClientId2($value);
break;
case 3:
$this->setTravelTimeHours($value);
break;
case 4:
$this->setTravelTimeMins($value);
break;
case 5:
$this->setTravelDistance($value);
break;
case 6:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DistancesPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setClientId1($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setClientId2($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setTravelTimeHours($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setTravelTimeMins($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setTravelDistance($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DistancesPeer::DATABASE_NAME);
if ($this->isColumnModified(DistancesPeer::ID)) $criteria->add(DistancesPeer::ID, $this->id);
if ($this->isColumnModified(DistancesPeer::CLIENT_ID_1)) $criteria->add(DistancesPeer::CLIENT_ID_1, $this->client_id_1);
if ($this->isColumnModified(DistancesPeer::CLIENT_ID_2)) $criteria->add(DistancesPeer::CLIENT_ID_2, $this->client_id_2);
if ($this->isColumnModified(DistancesPeer::TRAVEL_TIME_HOURS)) $criteria->add(DistancesPeer::TRAVEL_TIME_HOURS, $this->travel_time_hours);
if ($this->isColumnModified(DistancesPeer::TRAVEL_TIME_MINS)) $criteria->add(DistancesPeer::TRAVEL_TIME_MINS, $this->travel_time_mins);
if ($this->isColumnModified(DistancesPeer::TRAVEL_DISTANCE)) $criteria->add(DistancesPeer::TRAVEL_DISTANCE, $this->travel_distance);
if ($this->isColumnModified(DistancesPeer::UPDATED_AT)) $criteria->add(DistancesPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DistancesPeer::DATABASE_NAME);
$criteria->add(DistancesPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setClientId1($this->client_id_1);
$copyObj->setClientId2($this->client_id_2);
$copyObj->setTravelTimeHours($this->travel_time_hours);
$copyObj->setTravelTimeMins($this->travel_time_mins);
$copyObj->setTravelDistance($this->travel_distance);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DistancesPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,393 @@
<?php
abstract class BaseDistancesPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'distances';
const CLASS_DEFAULT = 'lib.model.Distances';
const NUM_COLUMNS = 7;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'distances.ID';
const CLIENT_ID_1 = 'distances.CLIENT_ID_1';
const CLIENT_ID_2 = 'distances.CLIENT_ID_2';
const TRAVEL_TIME_HOURS = 'distances.TRAVEL_TIME_HOURS';
const TRAVEL_TIME_MINS = 'distances.TRAVEL_TIME_MINS';
const TRAVEL_DISTANCE = 'distances.TRAVEL_DISTANCE';
const UPDATED_AT = 'distances.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'ClientId1', 'ClientId2', 'TravelTimeHours', 'TravelTimeMins', 'TravelDistance', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (DistancesPeer::ID, DistancesPeer::CLIENT_ID_1, DistancesPeer::CLIENT_ID_2, DistancesPeer::TRAVEL_TIME_HOURS, DistancesPeer::TRAVEL_TIME_MINS, DistancesPeer::TRAVEL_DISTANCE, DistancesPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'client_id_1', 'client_id_2', 'travel_time_hours', 'travel_time_mins', 'travel_distance', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ClientId1' => 1, 'ClientId2' => 2, 'TravelTimeHours' => 3, 'TravelTimeMins' => 4, 'TravelDistance' => 5, 'UpdatedAt' => 6, ),
BasePeer::TYPE_COLNAME => array (DistancesPeer::ID => 0, DistancesPeer::CLIENT_ID_1 => 1, DistancesPeer::CLIENT_ID_2 => 2, DistancesPeer::TRAVEL_TIME_HOURS => 3, DistancesPeer::TRAVEL_TIME_MINS => 4, DistancesPeer::TRAVEL_DISTANCE => 5, DistancesPeer::UPDATED_AT => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'client_id_1' => 1, 'client_id_2' => 2, 'travel_time_hours' => 3, 'travel_time_mins' => 4, 'travel_distance' => 5, 'updated_at' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DistancesMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DistancesMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DistancesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DistancesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DistancesPeer::ID);
$criteria->addSelectColumn(DistancesPeer::CLIENT_ID_1);
$criteria->addSelectColumn(DistancesPeer::CLIENT_ID_2);
$criteria->addSelectColumn(DistancesPeer::TRAVEL_TIME_HOURS);
$criteria->addSelectColumn(DistancesPeer::TRAVEL_TIME_MINS);
$criteria->addSelectColumn(DistancesPeer::TRAVEL_DISTANCE);
$criteria->addSelectColumn(DistancesPeer::UPDATED_AT);
}
const COUNT = 'COUNT(distances.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT distances.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DistancesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DistancesPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DistancesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DistancesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DistancesPeer::populateObjects(DistancesPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DistancesPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DistancesPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DistancesPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DistancesPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DistancesPeer::ID);
$selectCriteria->add(DistancesPeer::ID, $criteria->remove(DistancesPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DistancesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DistancesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Distances) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DistancesPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Distances $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DistancesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DistancesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DistancesPeer::DATABASE_NAME, DistancesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DistancesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DistancesPeer::DATABASE_NAME);
$criteria->add(DistancesPeer::ID, $pk);
$v = DistancesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DistancesPeer::ID, $pks, Criteria::IN);
$objs = DistancesPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDistancesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DistancesMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DistancesMapBuilder');
}

479
lib/model/om/BaseDropdown.php Executable file
View File

@ -0,0 +1,479 @@
<?php
abstract class BaseDropdown extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $menu = '<null>';
protected $value = '<null>';
protected $created_at;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getMenu()
{
return $this->menu;
}
public function getValue()
{
return $this->value;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DropdownPeer::ID;
}
}
public function setMenu($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->menu !== $v || $v === '<null>') {
$this->menu = $v;
$this->modifiedColumns[] = DropdownPeer::MENU;
}
}
public function setValue($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->value !== $v || $v === '<null>') {
$this->value = $v;
$this->modifiedColumns[] = DropdownPeer::VALUE;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = DropdownPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = DropdownPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->menu = $rs->getString($startcol + 1);
$this->value = $rs->getString($startcol + 2);
$this->created_at = $rs->getTimestamp($startcol + 3, null);
$this->updated_at = $rs->getTimestamp($startcol + 4, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating Dropdown object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DropdownPeer::DATABASE_NAME);
}
try {
$con->begin();
DropdownPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(DropdownPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(DropdownPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(DropdownPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DropdownPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += DropdownPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = DropdownPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DropdownPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getMenu();
break;
case 2:
return $this->getValue();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DropdownPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getMenu(),
$keys[2] => $this->getValue(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DropdownPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setMenu($value);
break;
case 2:
$this->setValue($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DropdownPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setMenu($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(DropdownPeer::DATABASE_NAME);
if ($this->isColumnModified(DropdownPeer::ID)) $criteria->add(DropdownPeer::ID, $this->id);
if ($this->isColumnModified(DropdownPeer::MENU)) $criteria->add(DropdownPeer::MENU, $this->menu);
if ($this->isColumnModified(DropdownPeer::VALUE)) $criteria->add(DropdownPeer::VALUE, $this->value);
if ($this->isColumnModified(DropdownPeer::CREATED_AT)) $criteria->add(DropdownPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(DropdownPeer::UPDATED_AT)) $criteria->add(DropdownPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(DropdownPeer::DATABASE_NAME);
$criteria->add(DropdownPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setMenu($this->menu);
$copyObj->setValue($this->value);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new DropdownPeer();
}
return self::$peer;
}
}

383
lib/model/om/BaseDropdownPeer.php Executable file
View File

@ -0,0 +1,383 @@
<?php
abstract class BaseDropdownPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'dropdown';
const CLASS_DEFAULT = 'lib.model.Dropdown';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'dropdown.ID';
const MENU = 'dropdown.MENU';
const VALUE = 'dropdown.VALUE';
const CREATED_AT = 'dropdown.CREATED_AT';
const UPDATED_AT = 'dropdown.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Menu', 'Value', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (DropdownPeer::ID, DropdownPeer::MENU, DropdownPeer::VALUE, DropdownPeer::CREATED_AT, DropdownPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'menu', 'value', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Menu' => 1, 'Value' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
BasePeer::TYPE_COLNAME => array (DropdownPeer::ID => 0, DropdownPeer::MENU => 1, DropdownPeer::VALUE => 2, DropdownPeer::CREATED_AT => 3, DropdownPeer::UPDATED_AT => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'menu' => 1, 'value' => 2, 'created_at' => 3, 'updated_at' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/DropdownMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.DropdownMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DropdownPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(DropdownPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DropdownPeer::ID);
$criteria->addSelectColumn(DropdownPeer::MENU);
$criteria->addSelectColumn(DropdownPeer::VALUE);
$criteria->addSelectColumn(DropdownPeer::CREATED_AT);
$criteria->addSelectColumn(DropdownPeer::UPDATED_AT);
}
const COUNT = 'COUNT(dropdown.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT dropdown.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DropdownPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DropdownPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DropdownPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DropdownPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return DropdownPeer::populateObjects(DropdownPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DropdownPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = DropdownPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return DropdownPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(DropdownPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(DropdownPeer::ID);
$selectCriteria->add(DropdownPeer::ID, $criteria->remove(DropdownPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DropdownPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DropdownPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Dropdown) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DropdownPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Dropdown $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DropdownPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DropdownPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DropdownPeer::DATABASE_NAME, DropdownPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DropdownPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DropdownPeer::DATABASE_NAME);
$criteria->add(DropdownPeer::ID, $pk);
$v = DropdownPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DropdownPeer::ID, $pks, Criteria::IN);
$objs = DropdownPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseDropdownPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/DropdownMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.DropdownMapBuilder');
}

View File

@ -0,0 +1,783 @@
<?php
abstract class BaseFinalDeviceReport extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $client_id;
protected $date;
protected $pass_fail;
protected $total_failed;
protected $total_passed;
protected $total_bp;
protected $total_trace;
protected $total_missed;
protected $total_outlets;
protected $contact;
protected $created_at;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getClientId()
{
return $this->client_id;
}
public function getDate()
{
return $this->date;
}
public function getPassFail()
{
return $this->pass_fail;
}
public function getTotalFailed()
{
return $this->total_failed;
}
public function getTotalPassed()
{
return $this->total_passed;
}
public function getTotalBp()
{
return $this->total_bp;
}
public function getTotalTrace()
{
return $this->total_trace;
}
public function getTotalMissed()
{
return $this->total_missed;
}
public function getTotalOutlets()
{
return $this->total_outlets;
}
public function getContact()
{
return $this->contact;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::ID;
}
}
public function setClientId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->client_id !== $v) {
$this->client_id = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::CLIENT_ID;
}
}
public function setDate($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->date !== $v) {
$this->date = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::DATE;
}
}
public function setPassFail($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->pass_fail !== $v) {
$this->pass_fail = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::PASS_FAIL;
}
}
public function setTotalFailed($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_failed !== $v) {
$this->total_failed = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_FAILED;
}
}
public function setTotalPassed($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_passed !== $v) {
$this->total_passed = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_PASSED;
}
}
public function setTotalBp($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_bp !== $v) {
$this->total_bp = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_BP;
}
}
public function setTotalTrace($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_trace !== $v) {
$this->total_trace = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_TRACE;
}
}
public function setTotalMissed($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_missed !== $v) {
$this->total_missed = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_MISSED;
}
}
public function setTotalOutlets($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->total_outlets !== $v) {
$this->total_outlets = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::TOTAL_OUTLETS;
}
}
public function setContact($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->contact !== $v) {
$this->contact = $v;
$this->modifiedColumns[] = FinalDeviceReportPeer::CONTACT;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = FinalDeviceReportPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = FinalDeviceReportPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->client_id = $rs->getString($startcol + 1);
$this->date = $rs->getString($startcol + 2);
$this->pass_fail = $rs->getString($startcol + 3);
$this->total_failed = $rs->getInt($startcol + 4);
$this->total_passed = $rs->getInt($startcol + 5);
$this->total_bp = $rs->getInt($startcol + 6);
$this->total_trace = $rs->getInt($startcol + 7);
$this->total_missed = $rs->getInt($startcol + 8);
$this->total_outlets = $rs->getInt($startcol + 9);
$this->contact = $rs->getString($startcol + 10);
$this->created_at = $rs->getTimestamp($startcol + 11, null);
$this->updated_at = $rs->getTimestamp($startcol + 12, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 13;
} catch (Exception $e) {
throw new PropelException("Error populating FinalDeviceReport object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(FinalDeviceReportPeer::DATABASE_NAME);
}
try {
$con->begin();
FinalDeviceReportPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(FinalDeviceReportPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(FinalDeviceReportPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(FinalDeviceReportPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = FinalDeviceReportPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += FinalDeviceReportPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = FinalDeviceReportPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = FinalDeviceReportPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getClientId();
break;
case 2:
return $this->getDate();
break;
case 3:
return $this->getPassFail();
break;
case 4:
return $this->getTotalFailed();
break;
case 5:
return $this->getTotalPassed();
break;
case 6:
return $this->getTotalBp();
break;
case 7:
return $this->getTotalTrace();
break;
case 8:
return $this->getTotalMissed();
break;
case 9:
return $this->getTotalOutlets();
break;
case 10:
return $this->getContact();
break;
case 11:
return $this->getCreatedAt();
break;
case 12:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = FinalDeviceReportPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getClientId(),
$keys[2] => $this->getDate(),
$keys[3] => $this->getPassFail(),
$keys[4] => $this->getTotalFailed(),
$keys[5] => $this->getTotalPassed(),
$keys[6] => $this->getTotalBp(),
$keys[7] => $this->getTotalTrace(),
$keys[8] => $this->getTotalMissed(),
$keys[9] => $this->getTotalOutlets(),
$keys[10] => $this->getContact(),
$keys[11] => $this->getCreatedAt(),
$keys[12] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = FinalDeviceReportPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setClientId($value);
break;
case 2:
$this->setDate($value);
break;
case 3:
$this->setPassFail($value);
break;
case 4:
$this->setTotalFailed($value);
break;
case 5:
$this->setTotalPassed($value);
break;
case 6:
$this->setTotalBp($value);
break;
case 7:
$this->setTotalTrace($value);
break;
case 8:
$this->setTotalMissed($value);
break;
case 9:
$this->setTotalOutlets($value);
break;
case 10:
$this->setContact($value);
break;
case 11:
$this->setCreatedAt($value);
break;
case 12:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = FinalDeviceReportPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setClientId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDate($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setPassFail($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setTotalFailed($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setTotalPassed($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setTotalBp($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setTotalTrace($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setTotalMissed($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setTotalOutlets($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setContact($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]);
}
public function buildCriteria()
{
$criteria = new Criteria(FinalDeviceReportPeer::DATABASE_NAME);
if ($this->isColumnModified(FinalDeviceReportPeer::ID)) $criteria->add(FinalDeviceReportPeer::ID, $this->id);
if ($this->isColumnModified(FinalDeviceReportPeer::CLIENT_ID)) $criteria->add(FinalDeviceReportPeer::CLIENT_ID, $this->client_id);
if ($this->isColumnModified(FinalDeviceReportPeer::DATE)) $criteria->add(FinalDeviceReportPeer::DATE, $this->date);
if ($this->isColumnModified(FinalDeviceReportPeer::PASS_FAIL)) $criteria->add(FinalDeviceReportPeer::PASS_FAIL, $this->pass_fail);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_FAILED)) $criteria->add(FinalDeviceReportPeer::TOTAL_FAILED, $this->total_failed);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_PASSED)) $criteria->add(FinalDeviceReportPeer::TOTAL_PASSED, $this->total_passed);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_BP)) $criteria->add(FinalDeviceReportPeer::TOTAL_BP, $this->total_bp);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_TRACE)) $criteria->add(FinalDeviceReportPeer::TOTAL_TRACE, $this->total_trace);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_MISSED)) $criteria->add(FinalDeviceReportPeer::TOTAL_MISSED, $this->total_missed);
if ($this->isColumnModified(FinalDeviceReportPeer::TOTAL_OUTLETS)) $criteria->add(FinalDeviceReportPeer::TOTAL_OUTLETS, $this->total_outlets);
if ($this->isColumnModified(FinalDeviceReportPeer::CONTACT)) $criteria->add(FinalDeviceReportPeer::CONTACT, $this->contact);
if ($this->isColumnModified(FinalDeviceReportPeer::CREATED_AT)) $criteria->add(FinalDeviceReportPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(FinalDeviceReportPeer::UPDATED_AT)) $criteria->add(FinalDeviceReportPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(FinalDeviceReportPeer::DATABASE_NAME);
$criteria->add(FinalDeviceReportPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setClientId($this->client_id);
$copyObj->setDate($this->date);
$copyObj->setPassFail($this->pass_fail);
$copyObj->setTotalFailed($this->total_failed);
$copyObj->setTotalPassed($this->total_passed);
$copyObj->setTotalBp($this->total_bp);
$copyObj->setTotalTrace($this->total_trace);
$copyObj->setTotalMissed($this->total_missed);
$copyObj->setTotalOutlets($this->total_outlets);
$copyObj->setContact($this->contact);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new FinalDeviceReportPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,423 @@
<?php
abstract class BaseFinalDeviceReportPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'final_device_report';
const CLASS_DEFAULT = 'lib.model.FinalDeviceReport';
const NUM_COLUMNS = 13;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'final_device_report.ID';
const CLIENT_ID = 'final_device_report.CLIENT_ID';
const DATE = 'final_device_report.DATE';
const PASS_FAIL = 'final_device_report.PASS_FAIL';
const TOTAL_FAILED = 'final_device_report.TOTAL_FAILED';
const TOTAL_PASSED = 'final_device_report.TOTAL_PASSED';
const TOTAL_BP = 'final_device_report.TOTAL_BP';
const TOTAL_TRACE = 'final_device_report.TOTAL_TRACE';
const TOTAL_MISSED = 'final_device_report.TOTAL_MISSED';
const TOTAL_OUTLETS = 'final_device_report.TOTAL_OUTLETS';
const CONTACT = 'final_device_report.CONTACT';
const CREATED_AT = 'final_device_report.CREATED_AT';
const UPDATED_AT = 'final_device_report.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'ClientId', 'Date', 'PassFail', 'TotalFailed', 'TotalPassed', 'TotalBp', 'TotalTrace', 'TotalMissed', 'TotalOutlets', 'Contact', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (FinalDeviceReportPeer::ID, FinalDeviceReportPeer::CLIENT_ID, FinalDeviceReportPeer::DATE, FinalDeviceReportPeer::PASS_FAIL, FinalDeviceReportPeer::TOTAL_FAILED, FinalDeviceReportPeer::TOTAL_PASSED, FinalDeviceReportPeer::TOTAL_BP, FinalDeviceReportPeer::TOTAL_TRACE, FinalDeviceReportPeer::TOTAL_MISSED, FinalDeviceReportPeer::TOTAL_OUTLETS, FinalDeviceReportPeer::CONTACT, FinalDeviceReportPeer::CREATED_AT, FinalDeviceReportPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'client_id', 'date', 'pass_fail', 'total_failed', 'total_passed', 'total_bp', 'total_trace', 'total_missed', 'total_outlets', 'contact', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ClientId' => 1, 'Date' => 2, 'PassFail' => 3, 'TotalFailed' => 4, 'TotalPassed' => 5, 'TotalBp' => 6, 'TotalTrace' => 7, 'TotalMissed' => 8, 'TotalOutlets' => 9, 'Contact' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, ),
BasePeer::TYPE_COLNAME => array (FinalDeviceReportPeer::ID => 0, FinalDeviceReportPeer::CLIENT_ID => 1, FinalDeviceReportPeer::DATE => 2, FinalDeviceReportPeer::PASS_FAIL => 3, FinalDeviceReportPeer::TOTAL_FAILED => 4, FinalDeviceReportPeer::TOTAL_PASSED => 5, FinalDeviceReportPeer::TOTAL_BP => 6, FinalDeviceReportPeer::TOTAL_TRACE => 7, FinalDeviceReportPeer::TOTAL_MISSED => 8, FinalDeviceReportPeer::TOTAL_OUTLETS => 9, FinalDeviceReportPeer::CONTACT => 10, FinalDeviceReportPeer::CREATED_AT => 11, FinalDeviceReportPeer::UPDATED_AT => 12, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'client_id' => 1, 'date' => 2, 'pass_fail' => 3, 'total_failed' => 4, 'total_passed' => 5, 'total_bp' => 6, 'total_trace' => 7, 'total_missed' => 8, 'total_outlets' => 9, 'contact' => 10, 'created_at' => 11, 'updated_at' => 12, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/FinalDeviceReportMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.FinalDeviceReportMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = FinalDeviceReportPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(FinalDeviceReportPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(FinalDeviceReportPeer::ID);
$criteria->addSelectColumn(FinalDeviceReportPeer::CLIENT_ID);
$criteria->addSelectColumn(FinalDeviceReportPeer::DATE);
$criteria->addSelectColumn(FinalDeviceReportPeer::PASS_FAIL);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_FAILED);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_PASSED);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_BP);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_TRACE);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_MISSED);
$criteria->addSelectColumn(FinalDeviceReportPeer::TOTAL_OUTLETS);
$criteria->addSelectColumn(FinalDeviceReportPeer::CONTACT);
$criteria->addSelectColumn(FinalDeviceReportPeer::CREATED_AT);
$criteria->addSelectColumn(FinalDeviceReportPeer::UPDATED_AT);
}
const COUNT = 'COUNT(final_device_report.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT final_device_report.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(FinalDeviceReportPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(FinalDeviceReportPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = FinalDeviceReportPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = FinalDeviceReportPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return FinalDeviceReportPeer::populateObjects(FinalDeviceReportPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
FinalDeviceReportPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = FinalDeviceReportPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return FinalDeviceReportPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(FinalDeviceReportPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(FinalDeviceReportPeer::ID);
$selectCriteria->add(FinalDeviceReportPeer::ID, $criteria->remove(FinalDeviceReportPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(FinalDeviceReportPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(FinalDeviceReportPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof FinalDeviceReport) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(FinalDeviceReportPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(FinalDeviceReport $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(FinalDeviceReportPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(FinalDeviceReportPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(FinalDeviceReportPeer::DATABASE_NAME, FinalDeviceReportPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = FinalDeviceReportPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(FinalDeviceReportPeer::DATABASE_NAME);
$criteria->add(FinalDeviceReportPeer::ID, $pk);
$v = FinalDeviceReportPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(FinalDeviceReportPeer::ID, $pks, Criteria::IN);
$objs = FinalDeviceReportPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseFinalDeviceReportPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/FinalDeviceReportMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.FinalDeviceReportMapBuilder');
}

720
lib/model/om/BaseJobStatus.php Executable file
View File

@ -0,0 +1,720 @@
<?php
abstract class BaseJobStatus extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $status_name = '<null>';
protected $created_at;
protected $updated_at;
protected $workorder_type_id;
protected $collWorkorders;
protected $lastWorkorderCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getStatusName()
{
return $this->status_name;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getWorkorderTypeId()
{
return $this->workorder_type_id;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = JobStatusPeer::ID;
}
}
public function setStatusName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->status_name !== $v || $v === '<null>') {
$this->status_name = $v;
$this->modifiedColumns[] = JobStatusPeer::STATUS_NAME;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = JobStatusPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = JobStatusPeer::UPDATED_AT;
}
}
public function setWorkorderTypeId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->workorder_type_id !== $v) {
$this->workorder_type_id = $v;
$this->modifiedColumns[] = JobStatusPeer::WORKORDER_TYPE_ID;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->status_name = $rs->getString($startcol + 1);
$this->created_at = $rs->getTimestamp($startcol + 2, null);
$this->updated_at = $rs->getTimestamp($startcol + 3, null);
$this->workorder_type_id = $rs->getInt($startcol + 4);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating JobStatus object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(JobStatusPeer::DATABASE_NAME);
}
try {
$con->begin();
JobStatusPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(JobStatusPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(JobStatusPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(JobStatusPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = JobStatusPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += JobStatusPeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = JobStatusPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = JobStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getStatusName();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
case 4:
return $this->getWorkorderTypeId();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = JobStatusPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getStatusName(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
$keys[4] => $this->getWorkorderTypeId(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = JobStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setStatusName($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
case 4:
$this->setWorkorderTypeId($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = JobStatusPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setStatusName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setWorkorderTypeId($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(JobStatusPeer::DATABASE_NAME);
if ($this->isColumnModified(JobStatusPeer::ID)) $criteria->add(JobStatusPeer::ID, $this->id);
if ($this->isColumnModified(JobStatusPeer::STATUS_NAME)) $criteria->add(JobStatusPeer::STATUS_NAME, $this->status_name);
if ($this->isColumnModified(JobStatusPeer::CREATED_AT)) $criteria->add(JobStatusPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(JobStatusPeer::UPDATED_AT)) $criteria->add(JobStatusPeer::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(JobStatusPeer::WORKORDER_TYPE_ID)) $criteria->add(JobStatusPeer::WORKORDER_TYPE_ID, $this->workorder_type_id);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(JobStatusPeer::DATABASE_NAME);
$criteria->add(JobStatusPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setStatusName($this->status_name);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setWorkorderTypeId($this->workorder_type_id);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getWorkorders() as $relObj) {
$copyObj->addWorkorder($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new JobStatusPeer();
}
return self::$peer;
}
public function initWorkorders()
{
if ($this->collWorkorders === null) {
$this->collWorkorders = array();
}
}
public function getWorkorders($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function countWorkorders($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
return WorkorderPeer::doCount($criteria, $distinct, $con);
}
public function addWorkorder(Workorder $l)
{
$this->collWorkorders[] = $l;
$l->setJobStatus($this);
}
public function getWorkordersJoinDevice($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinClient($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinJobType($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinJobType($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinJobType($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinWorkorderType($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinWorkorderType($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_STATUS_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinWorkorderType($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
}

View File

@ -0,0 +1,383 @@
<?php
abstract class BaseJobStatusPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'job_status';
const CLASS_DEFAULT = 'lib.model.JobStatus';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'job_status.ID';
const STATUS_NAME = 'job_status.STATUS_NAME';
const CREATED_AT = 'job_status.CREATED_AT';
const UPDATED_AT = 'job_status.UPDATED_AT';
const WORKORDER_TYPE_ID = 'job_status.WORKORDER_TYPE_ID';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'StatusName', 'CreatedAt', 'UpdatedAt', 'WorkorderTypeId', ),
BasePeer::TYPE_COLNAME => array (JobStatusPeer::ID, JobStatusPeer::STATUS_NAME, JobStatusPeer::CREATED_AT, JobStatusPeer::UPDATED_AT, JobStatusPeer::WORKORDER_TYPE_ID, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'status_name', 'created_at', 'updated_at', 'workorder_type_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'StatusName' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, 'WorkorderTypeId' => 4, ),
BasePeer::TYPE_COLNAME => array (JobStatusPeer::ID => 0, JobStatusPeer::STATUS_NAME => 1, JobStatusPeer::CREATED_AT => 2, JobStatusPeer::UPDATED_AT => 3, JobStatusPeer::WORKORDER_TYPE_ID => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'status_name' => 1, 'created_at' => 2, 'updated_at' => 3, 'workorder_type_id' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/JobStatusMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.JobStatusMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = JobStatusPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(JobStatusPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(JobStatusPeer::ID);
$criteria->addSelectColumn(JobStatusPeer::STATUS_NAME);
$criteria->addSelectColumn(JobStatusPeer::CREATED_AT);
$criteria->addSelectColumn(JobStatusPeer::UPDATED_AT);
$criteria->addSelectColumn(JobStatusPeer::WORKORDER_TYPE_ID);
}
const COUNT = 'COUNT(job_status.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT job_status.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(JobStatusPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(JobStatusPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = JobStatusPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = JobStatusPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return JobStatusPeer::populateObjects(JobStatusPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
JobStatusPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = JobStatusPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return JobStatusPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(JobStatusPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(JobStatusPeer::ID);
$selectCriteria->add(JobStatusPeer::ID, $criteria->remove(JobStatusPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(JobStatusPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(JobStatusPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof JobStatus) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(JobStatusPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(JobStatus $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(JobStatusPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(JobStatusPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(JobStatusPeer::DATABASE_NAME, JobStatusPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = JobStatusPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(JobStatusPeer::DATABASE_NAME);
$criteria->add(JobStatusPeer::ID, $pk);
$v = JobStatusPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(JobStatusPeer::ID, $pks, Criteria::IN);
$objs = JobStatusPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseJobStatusPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/JobStatusMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.JobStatusMapBuilder');
}

682
lib/model/om/BaseJobType.php Executable file
View File

@ -0,0 +1,682 @@
<?php
abstract class BaseJobType extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $type_name = '<null>';
protected $created_at;
protected $updated_at;
protected $collWorkorders;
protected $lastWorkorderCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getTypeName()
{
return $this->type_name;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = JobTypePeer::ID;
}
}
public function setTypeName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->type_name !== $v || $v === '<null>') {
$this->type_name = $v;
$this->modifiedColumns[] = JobTypePeer::TYPE_NAME;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = JobTypePeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = JobTypePeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->type_name = $rs->getString($startcol + 1);
$this->created_at = $rs->getTimestamp($startcol + 2, null);
$this->updated_at = $rs->getTimestamp($startcol + 3, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 4;
} catch (Exception $e) {
throw new PropelException("Error populating JobType object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(JobTypePeer::DATABASE_NAME);
}
try {
$con->begin();
JobTypePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(JobTypePeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(JobTypePeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(JobTypePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = JobTypePeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += JobTypePeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = JobTypePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = JobTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getTypeName();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = JobTypePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getTypeName(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = JobTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setTypeName($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = JobTypePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setTypeName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
}
public function buildCriteria()
{
$criteria = new Criteria(JobTypePeer::DATABASE_NAME);
if ($this->isColumnModified(JobTypePeer::ID)) $criteria->add(JobTypePeer::ID, $this->id);
if ($this->isColumnModified(JobTypePeer::TYPE_NAME)) $criteria->add(JobTypePeer::TYPE_NAME, $this->type_name);
if ($this->isColumnModified(JobTypePeer::CREATED_AT)) $criteria->add(JobTypePeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(JobTypePeer::UPDATED_AT)) $criteria->add(JobTypePeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(JobTypePeer::DATABASE_NAME);
$criteria->add(JobTypePeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setTypeName($this->type_name);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getWorkorders() as $relObj) {
$copyObj->addWorkorder($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new JobTypePeer();
}
return self::$peer;
}
public function initWorkorders()
{
if ($this->collWorkorders === null) {
$this->collWorkorders = array();
}
}
public function getWorkorders($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function countWorkorders($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
return WorkorderPeer::doCount($criteria, $distinct, $con);
}
public function addWorkorder(Workorder $l)
{
$this->collWorkorders[] = $l;
$l->setJobType($this);
}
public function getWorkordersJoinDevice($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinClient($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinJobStatus($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinJobStatus($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinJobStatus($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinWorkorderType($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinWorkorderType($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::JOB_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinWorkorderType($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
}

378
lib/model/om/BaseJobTypePeer.php Executable file
View File

@ -0,0 +1,378 @@
<?php
abstract class BaseJobTypePeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'job_type';
const CLASS_DEFAULT = 'lib.model.JobType';
const NUM_COLUMNS = 4;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'job_type.ID';
const TYPE_NAME = 'job_type.TYPE_NAME';
const CREATED_AT = 'job_type.CREATED_AT';
const UPDATED_AT = 'job_type.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'TypeName', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (JobTypePeer::ID, JobTypePeer::TYPE_NAME, JobTypePeer::CREATED_AT, JobTypePeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'type_name', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TypeName' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
BasePeer::TYPE_COLNAME => array (JobTypePeer::ID => 0, JobTypePeer::TYPE_NAME => 1, JobTypePeer::CREATED_AT => 2, JobTypePeer::UPDATED_AT => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'type_name' => 1, 'created_at' => 2, 'updated_at' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/JobTypeMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.JobTypeMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = JobTypePeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(JobTypePeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(JobTypePeer::ID);
$criteria->addSelectColumn(JobTypePeer::TYPE_NAME);
$criteria->addSelectColumn(JobTypePeer::CREATED_AT);
$criteria->addSelectColumn(JobTypePeer::UPDATED_AT);
}
const COUNT = 'COUNT(job_type.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT job_type.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(JobTypePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(JobTypePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = JobTypePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = JobTypePeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return JobTypePeer::populateObjects(JobTypePeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
JobTypePeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = JobTypePeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return JobTypePeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(JobTypePeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(JobTypePeer::ID);
$selectCriteria->add(JobTypePeer::ID, $criteria->remove(JobTypePeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(JobTypePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(JobTypePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof JobType) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(JobTypePeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(JobType $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(JobTypePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(JobTypePeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(JobTypePeer::DATABASE_NAME, JobTypePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = JobTypePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(JobTypePeer::DATABASE_NAME);
$criteria->add(JobTypePeer::ID, $pk);
$v = JobTypePeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(JobTypePeer::ID, $pks, Criteria::IN);
$objs = JobTypePeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseJobTypePeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/JobTypeMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.JobTypeMapBuilder');
}

580
lib/model/om/BaseLocation.php Executable file
View File

@ -0,0 +1,580 @@
<?php
abstract class BaseLocation extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $latitude = '<null>';
protected $longitude = '<null>';
protected $created_at;
protected $updated_at;
protected $collClients;
protected $lastClientCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getLatitude()
{
return $this->latitude;
}
public function getLongitude()
{
return $this->longitude;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = LocationPeer::ID;
}
}
public function setLatitude($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->latitude !== $v || $v === '<null>') {
$this->latitude = $v;
$this->modifiedColumns[] = LocationPeer::LATITUDE;
}
}
public function setLongitude($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->longitude !== $v || $v === '<null>') {
$this->longitude = $v;
$this->modifiedColumns[] = LocationPeer::LONGITUDE;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = LocationPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = LocationPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->latitude = $rs->getString($startcol + 1);
$this->longitude = $rs->getString($startcol + 2);
$this->created_at = $rs->getTimestamp($startcol + 3, null);
$this->updated_at = $rs->getTimestamp($startcol + 4, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating Location object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(LocationPeer::DATABASE_NAME);
}
try {
$con->begin();
LocationPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(LocationPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(LocationPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(LocationPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = LocationPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += LocationPeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collClients !== null) {
foreach($this->collClients as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = LocationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collClients !== null) {
foreach($this->collClients as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = LocationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getLatitude();
break;
case 2:
return $this->getLongitude();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = LocationPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getLatitude(),
$keys[2] => $this->getLongitude(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = LocationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setLatitude($value);
break;
case 2:
$this->setLongitude($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = LocationPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setLatitude($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setLongitude($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(LocationPeer::DATABASE_NAME);
if ($this->isColumnModified(LocationPeer::ID)) $criteria->add(LocationPeer::ID, $this->id);
if ($this->isColumnModified(LocationPeer::LATITUDE)) $criteria->add(LocationPeer::LATITUDE, $this->latitude);
if ($this->isColumnModified(LocationPeer::LONGITUDE)) $criteria->add(LocationPeer::LONGITUDE, $this->longitude);
if ($this->isColumnModified(LocationPeer::CREATED_AT)) $criteria->add(LocationPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(LocationPeer::UPDATED_AT)) $criteria->add(LocationPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(LocationPeer::DATABASE_NAME);
$criteria->add(LocationPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setLatitude($this->latitude);
$copyObj->setLongitude($this->longitude);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getClients() as $relObj) {
$copyObj->addClient($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new LocationPeer();
}
return self::$peer;
}
public function initClients()
{
if ($this->collClients === null) {
$this->collClients = array();
}
}
public function getClients($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseClientPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collClients === null) {
if ($this->isNew()) {
$this->collClients = array();
} else {
$criteria->add(ClientPeer::LOCATION_ID, $this->getId());
ClientPeer::addSelectColumns($criteria);
$this->collClients = ClientPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(ClientPeer::LOCATION_ID, $this->getId());
ClientPeer::addSelectColumns($criteria);
if (!isset($this->lastClientCriteria) || !$this->lastClientCriteria->equals($criteria)) {
$this->collClients = ClientPeer::doSelect($criteria, $con);
}
}
}
$this->lastClientCriteria = $criteria;
return $this->collClients;
}
public function countClients($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseClientPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(ClientPeer::LOCATION_ID, $this->getId());
return ClientPeer::doCount($criteria, $distinct, $con);
}
public function addClient(Client $l)
{
$this->collClients[] = $l;
$l->setLocation($this);
}
}

383
lib/model/om/BaseLocationPeer.php Executable file
View File

@ -0,0 +1,383 @@
<?php
abstract class BaseLocationPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'location';
const CLASS_DEFAULT = 'lib.model.Location';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'location.ID';
const LATITUDE = 'location.LATITUDE';
const LONGITUDE = 'location.LONGITUDE';
const CREATED_AT = 'location.CREATED_AT';
const UPDATED_AT = 'location.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Latitude', 'Longitude', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (LocationPeer::ID, LocationPeer::LATITUDE, LocationPeer::LONGITUDE, LocationPeer::CREATED_AT, LocationPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'latitude', 'longitude', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Latitude' => 1, 'Longitude' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
BasePeer::TYPE_COLNAME => array (LocationPeer::ID => 0, LocationPeer::LATITUDE => 1, LocationPeer::LONGITUDE => 2, LocationPeer::CREATED_AT => 3, LocationPeer::UPDATED_AT => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'latitude' => 1, 'longitude' => 2, 'created_at' => 3, 'updated_at' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/LocationMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.LocationMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = LocationPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(LocationPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(LocationPeer::ID);
$criteria->addSelectColumn(LocationPeer::LATITUDE);
$criteria->addSelectColumn(LocationPeer::LONGITUDE);
$criteria->addSelectColumn(LocationPeer::CREATED_AT);
$criteria->addSelectColumn(LocationPeer::UPDATED_AT);
}
const COUNT = 'COUNT(location.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT location.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(LocationPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(LocationPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = LocationPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = LocationPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return LocationPeer::populateObjects(LocationPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
LocationPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = LocationPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return LocationPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(LocationPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(LocationPeer::ID);
$selectCriteria->add(LocationPeer::ID, $criteria->remove(LocationPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(LocationPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(LocationPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Location) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(LocationPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Location $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(LocationPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(LocationPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(LocationPeer::DATABASE_NAME, LocationPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = LocationPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(LocationPeer::DATABASE_NAME);
$criteria->add(LocationPeer::ID, $pk);
$v = LocationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(LocationPeer::ID, $pks, Criteria::IN);
$objs = LocationPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseLocationPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/LocationMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.LocationMapBuilder');
}

View File

@ -0,0 +1,583 @@
<?php
abstract class BaseQualifications extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $user_id;
protected $device_id;
protected $created_at;
protected $updated_at;
protected $aUser;
protected $aDevice;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getUserId()
{
return $this->user_id;
}
public function getDeviceId()
{
return $this->device_id;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = QualificationsPeer::ID;
}
}
public function setUserId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->user_id !== $v) {
$this->user_id = $v;
$this->modifiedColumns[] = QualificationsPeer::USER_ID;
}
if ($this->aUser !== null && $this->aUser->getId() !== $v) {
$this->aUser = null;
}
}
public function setDeviceId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->device_id !== $v) {
$this->device_id = $v;
$this->modifiedColumns[] = QualificationsPeer::DEVICE_ID;
}
if ($this->aDevice !== null && $this->aDevice->getId() !== $v) {
$this->aDevice = null;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = QualificationsPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = QualificationsPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->user_id = $rs->getInt($startcol + 1);
$this->device_id = $rs->getInt($startcol + 2);
$this->created_at = $rs->getTimestamp($startcol + 3, null);
$this->updated_at = $rs->getTimestamp($startcol + 4, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating Qualifications object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(QualificationsPeer::DATABASE_NAME);
}
try {
$con->begin();
QualificationsPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(QualificationsPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(QualificationsPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(QualificationsPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->aUser !== null) {
if ($this->aUser->isModified()) {
$affectedRows += $this->aUser->save($con);
}
$this->setUser($this->aUser);
}
if ($this->aDevice !== null) {
if ($this->aDevice->isModified()) {
$affectedRows += $this->aDevice->save($con);
}
$this->setDevice($this->aDevice);
}
if ($this->isModified()) {
if ($this->isNew()) {
$pk = QualificationsPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += QualificationsPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if ($this->aDevice !== null) {
if (!$this->aDevice->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aDevice->getValidationFailures());
}
}
if (($retval = QualificationsPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = QualificationsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getUserId();
break;
case 2:
return $this->getDeviceId();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = QualificationsPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getUserId(),
$keys[2] => $this->getDeviceId(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = QualificationsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setUserId($value);
break;
case 2:
$this->setDeviceId($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = QualificationsPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDeviceId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(QualificationsPeer::DATABASE_NAME);
if ($this->isColumnModified(QualificationsPeer::ID)) $criteria->add(QualificationsPeer::ID, $this->id);
if ($this->isColumnModified(QualificationsPeer::USER_ID)) $criteria->add(QualificationsPeer::USER_ID, $this->user_id);
if ($this->isColumnModified(QualificationsPeer::DEVICE_ID)) $criteria->add(QualificationsPeer::DEVICE_ID, $this->device_id);
if ($this->isColumnModified(QualificationsPeer::CREATED_AT)) $criteria->add(QualificationsPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(QualificationsPeer::UPDATED_AT)) $criteria->add(QualificationsPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(QualificationsPeer::DATABASE_NAME);
$criteria->add(QualificationsPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setUserId($this->user_id);
$copyObj->setDeviceId($this->device_id);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new QualificationsPeer();
}
return self::$peer;
}
public function setUser($v)
{
if ($v === null) {
$this->setUserId(NULL);
} else {
$this->setUserId($v->getId());
}
$this->aUser = $v;
}
public function getUser($con = null)
{
include_once 'lib/model/om/BaseUserPeer.php';
if ($this->aUser === null && ($this->user_id !== null)) {
$this->aUser = UserPeer::retrieveByPK($this->user_id, $con);
}
return $this->aUser;
}
public function setDevice($v)
{
if ($v === null) {
$this->setDeviceId(NULL);
} else {
$this->setDeviceId($v->getId());
}
$this->aDevice = $v;
}
public function getDevice($con = null)
{
include_once 'lib/model/om/BaseDevicePeer.php';
if ($this->aDevice === null && ($this->device_id !== null)) {
$this->aDevice = DevicePeer::retrieveByPK($this->device_id, $con);
}
return $this->aDevice;
}
}

View File

@ -0,0 +1,819 @@
<?php
abstract class BaseQualificationsPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'qualifications';
const CLASS_DEFAULT = 'lib.model.Qualifications';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'qualifications.ID';
const USER_ID = 'qualifications.USER_ID';
const DEVICE_ID = 'qualifications.DEVICE_ID';
const CREATED_AT = 'qualifications.CREATED_AT';
const UPDATED_AT = 'qualifications.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'UserId', 'DeviceId', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (QualificationsPeer::ID, QualificationsPeer::USER_ID, QualificationsPeer::DEVICE_ID, QualificationsPeer::CREATED_AT, QualificationsPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'device_id', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'DeviceId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
BasePeer::TYPE_COLNAME => array (QualificationsPeer::ID => 0, QualificationsPeer::USER_ID => 1, QualificationsPeer::DEVICE_ID => 2, QualificationsPeer::CREATED_AT => 3, QualificationsPeer::UPDATED_AT => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'device_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/QualificationsMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.QualificationsMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = QualificationsPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(QualificationsPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(QualificationsPeer::ID);
$criteria->addSelectColumn(QualificationsPeer::USER_ID);
$criteria->addSelectColumn(QualificationsPeer::DEVICE_ID);
$criteria->addSelectColumn(QualificationsPeer::CREATED_AT);
$criteria->addSelectColumn(QualificationsPeer::UPDATED_AT);
}
const COUNT = 'COUNT(qualifications.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT qualifications.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = QualificationsPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return QualificationsPeer::populateObjects(QualificationsPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
QualificationsPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = QualificationsPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doCountJoinDevice(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinUser(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
QualificationsPeer::addSelectColumns($c);
$startcol = (QualificationsPeer::NUM_COLUMNS - QualificationsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
UserPeer::addSelectColumns($c);
$c->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = QualificationsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = UserPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addQualifications($obj1); break;
}
}
if ($newObject) {
$obj2->initQualificationss();
$obj2->addQualifications($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doSelectJoinDevice(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
QualificationsPeer::addSelectColumns($c);
$startcol = (QualificationsPeer::NUM_COLUMNS - QualificationsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DevicePeer::addSelectColumns($c);
$c->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = QualificationsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getDevice(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addQualifications($obj1); break;
}
}
if ($newObject) {
$obj2->initQualificationss();
$obj2->addQualifications($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$criteria->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
QualificationsPeer::addSelectColumns($c);
$startcol2 = (QualificationsPeer::NUM_COLUMNS - QualificationsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
UserPeer::addSelectColumns($c);
$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
DevicePeer::addSelectColumns($c);
$startcol4 = $startcol3 + DevicePeer::NUM_COLUMNS;
$c->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$c->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = QualificationsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = UserPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addQualifications($obj1); break;
}
}
if ($newObject) {
$obj2->initQualificationss();
$obj2->addQualifications($obj1);
}
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj3 = new $cls();
$obj3->hydrate($rs, $startcol3);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj3 = $temp_obj1->getDevice(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
$newObject = false;
$temp_obj3->addQualifications($obj1); break;
}
}
if ($newObject) {
$obj3->initQualificationss();
$obj3->addQualifications($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doCountJoinAllExceptDevice(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(QualificationsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(QualificationsPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$rs = QualificationsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAllExceptUser(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
QualificationsPeer::addSelectColumns($c);
$startcol2 = (QualificationsPeer::NUM_COLUMNS - QualificationsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DevicePeer::addSelectColumns($c);
$startcol3 = $startcol2 + DevicePeer::NUM_COLUMNS;
$c->addJoin(QualificationsPeer::DEVICE_ID, DevicePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = QualificationsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = DevicePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getDevice(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addQualifications($obj1);
break;
}
}
if ($newObject) {
$obj2->initQualificationss();
$obj2->addQualifications($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function doSelectJoinAllExceptDevice(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
QualificationsPeer::addSelectColumns($c);
$startcol2 = (QualificationsPeer::NUM_COLUMNS - QualificationsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
UserPeer::addSelectColumns($c);
$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
$c->addJoin(QualificationsPeer::USER_ID, UserPeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = QualificationsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = UserPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addQualifications($obj1);
break;
}
}
if ($newObject) {
$obj2->initQualificationss();
$obj2->addQualifications($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return QualificationsPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(QualificationsPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(QualificationsPeer::ID);
$selectCriteria->add(QualificationsPeer::ID, $criteria->remove(QualificationsPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(QualificationsPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(QualificationsPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Qualifications) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(QualificationsPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Qualifications $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(QualificationsPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(QualificationsPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(QualificationsPeer::DATABASE_NAME, QualificationsPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = QualificationsPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(QualificationsPeer::DATABASE_NAME);
$criteria->add(QualificationsPeer::ID, $pk);
$v = QualificationsPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(QualificationsPeer::ID, $pks, Criteria::IN);
$objs = QualificationsPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseQualificationsPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/QualificationsMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.QualificationsMapBuilder');
}

View File

@ -0,0 +1,653 @@
<?php
abstract class BaseSpecification extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $device_name;
protected $manufacturer;
protected $model_number;
protected $created_at;
protected $updated_at;
protected $collDevices;
protected $lastDeviceCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getDeviceName()
{
return $this->device_name;
}
public function getManufacturer()
{
return $this->manufacturer;
}
public function getModelNumber()
{
return $this->model_number;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = SpecificationPeer::ID;
}
}
public function setDeviceName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->device_name !== $v) {
$this->device_name = $v;
$this->modifiedColumns[] = SpecificationPeer::DEVICE_NAME;
}
}
public function setManufacturer($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->manufacturer !== $v) {
$this->manufacturer = $v;
$this->modifiedColumns[] = SpecificationPeer::MANUFACTURER;
}
}
public function setModelNumber($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->model_number !== $v) {
$this->model_number = $v;
$this->modifiedColumns[] = SpecificationPeer::MODEL_NUMBER;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = SpecificationPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = SpecificationPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->device_name = $rs->getString($startcol + 1);
$this->manufacturer = $rs->getString($startcol + 2);
$this->model_number = $rs->getString($startcol + 3);
$this->created_at = $rs->getTimestamp($startcol + 4, null);
$this->updated_at = $rs->getTimestamp($startcol + 5, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 6;
} catch (Exception $e) {
throw new PropelException("Error populating Specification object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(SpecificationPeer::DATABASE_NAME);
}
try {
$con->begin();
SpecificationPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(SpecificationPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(SpecificationPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(SpecificationPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = SpecificationPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += SpecificationPeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collDevices !== null) {
foreach($this->collDevices as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = SpecificationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collDevices !== null) {
foreach($this->collDevices as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = SpecificationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getDeviceName();
break;
case 2:
return $this->getManufacturer();
break;
case 3:
return $this->getModelNumber();
break;
case 4:
return $this->getCreatedAt();
break;
case 5:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = SpecificationPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getDeviceName(),
$keys[2] => $this->getManufacturer(),
$keys[3] => $this->getModelNumber(),
$keys[4] => $this->getCreatedAt(),
$keys[5] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = SpecificationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setDeviceName($value);
break;
case 2:
$this->setManufacturer($value);
break;
case 3:
$this->setModelNumber($value);
break;
case 4:
$this->setCreatedAt($value);
break;
case 5:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = SpecificationPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDeviceName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setManufacturer($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setModelNumber($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
}
public function buildCriteria()
{
$criteria = new Criteria(SpecificationPeer::DATABASE_NAME);
if ($this->isColumnModified(SpecificationPeer::ID)) $criteria->add(SpecificationPeer::ID, $this->id);
if ($this->isColumnModified(SpecificationPeer::DEVICE_NAME)) $criteria->add(SpecificationPeer::DEVICE_NAME, $this->device_name);
if ($this->isColumnModified(SpecificationPeer::MANUFACTURER)) $criteria->add(SpecificationPeer::MANUFACTURER, $this->manufacturer);
if ($this->isColumnModified(SpecificationPeer::MODEL_NUMBER)) $criteria->add(SpecificationPeer::MODEL_NUMBER, $this->model_number);
if ($this->isColumnModified(SpecificationPeer::CREATED_AT)) $criteria->add(SpecificationPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(SpecificationPeer::UPDATED_AT)) $criteria->add(SpecificationPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(SpecificationPeer::DATABASE_NAME);
$criteria->add(SpecificationPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDeviceName($this->device_name);
$copyObj->setManufacturer($this->manufacturer);
$copyObj->setModelNumber($this->model_number);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getDevices() as $relObj) {
$copyObj->addDevice($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new SpecificationPeer();
}
return self::$peer;
}
public function initDevices()
{
if ($this->collDevices === null) {
$this->collDevices = array();
}
}
public function getDevices($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseDevicePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDevices === null) {
if ($this->isNew()) {
$this->collDevices = array();
} else {
$criteria->add(DevicePeer::SPECIFICATION_ID, $this->getId());
DevicePeer::addSelectColumns($criteria);
$this->collDevices = DevicePeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(DevicePeer::SPECIFICATION_ID, $this->getId());
DevicePeer::addSelectColumns($criteria);
if (!isset($this->lastDeviceCriteria) || !$this->lastDeviceCriteria->equals($criteria)) {
$this->collDevices = DevicePeer::doSelect($criteria, $con);
}
}
}
$this->lastDeviceCriteria = $criteria;
return $this->collDevices;
}
public function countDevices($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseDevicePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(DevicePeer::SPECIFICATION_ID, $this->getId());
return DevicePeer::doCount($criteria, $distinct, $con);
}
public function addDevice(Device $l)
{
$this->collDevices[] = $l;
$l->setSpecification($this);
}
public function getDevicesJoinClient($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseDevicePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDevices === null) {
if ($this->isNew()) {
$this->collDevices = array();
} else {
$criteria->add(DevicePeer::SPECIFICATION_ID, $this->getId());
$this->collDevices = DevicePeer::doSelectJoinClient($criteria, $con);
}
} else {
$criteria->add(DevicePeer::SPECIFICATION_ID, $this->getId());
if (!isset($this->lastDeviceCriteria) || !$this->lastDeviceCriteria->equals($criteria)) {
$this->collDevices = DevicePeer::doSelectJoinClient($criteria, $con);
}
}
$this->lastDeviceCriteria = $criteria;
return $this->collDevices;
}
}

View File

@ -0,0 +1,388 @@
<?php
abstract class BaseSpecificationPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'specification';
const CLASS_DEFAULT = 'lib.model.Specification';
const NUM_COLUMNS = 6;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'specification.ID';
const DEVICE_NAME = 'specification.DEVICE_NAME';
const MANUFACTURER = 'specification.MANUFACTURER';
const MODEL_NUMBER = 'specification.MODEL_NUMBER';
const CREATED_AT = 'specification.CREATED_AT';
const UPDATED_AT = 'specification.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'DeviceName', 'Manufacturer', 'ModelNumber', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (SpecificationPeer::ID, SpecificationPeer::DEVICE_NAME, SpecificationPeer::MANUFACTURER, SpecificationPeer::MODEL_NUMBER, SpecificationPeer::CREATED_AT, SpecificationPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'device_name', 'manufacturer', 'model_number', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DeviceName' => 1, 'Manufacturer' => 2, 'ModelNumber' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
BasePeer::TYPE_COLNAME => array (SpecificationPeer::ID => 0, SpecificationPeer::DEVICE_NAME => 1, SpecificationPeer::MANUFACTURER => 2, SpecificationPeer::MODEL_NUMBER => 3, SpecificationPeer::CREATED_AT => 4, SpecificationPeer::UPDATED_AT => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'device_name' => 1, 'manufacturer' => 2, 'model_number' => 3, 'created_at' => 4, 'updated_at' => 5, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/SpecificationMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.SpecificationMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = SpecificationPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(SpecificationPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(SpecificationPeer::ID);
$criteria->addSelectColumn(SpecificationPeer::DEVICE_NAME);
$criteria->addSelectColumn(SpecificationPeer::MANUFACTURER);
$criteria->addSelectColumn(SpecificationPeer::MODEL_NUMBER);
$criteria->addSelectColumn(SpecificationPeer::CREATED_AT);
$criteria->addSelectColumn(SpecificationPeer::UPDATED_AT);
}
const COUNT = 'COUNT(specification.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT specification.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(SpecificationPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(SpecificationPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = SpecificationPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = SpecificationPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return SpecificationPeer::populateObjects(SpecificationPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
SpecificationPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = SpecificationPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return SpecificationPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(SpecificationPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(SpecificationPeer::ID);
$selectCriteria->add(SpecificationPeer::ID, $criteria->remove(SpecificationPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(SpecificationPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(SpecificationPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof Specification) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(SpecificationPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(Specification $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(SpecificationPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(SpecificationPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(SpecificationPeer::DATABASE_NAME, SpecificationPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = SpecificationPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(SpecificationPeer::DATABASE_NAME);
$criteria->add(SpecificationPeer::ID, $pk);
$v = SpecificationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(SpecificationPeer::ID, $pks, Criteria::IN);
$objs = SpecificationPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseSpecificationPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/SpecificationMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.SpecificationMapBuilder');
}

View File

@ -0,0 +1,528 @@
<?php
abstract class BaseTechDistances extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $tech_id;
protected $client_id;
protected $travel_time_hours;
protected $travel_time_mins;
protected $travel_distance;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getTechId()
{
return $this->tech_id;
}
public function getClientId()
{
return $this->client_id;
}
public function getTravelTimeHours()
{
return $this->travel_time_hours;
}
public function getTravelTimeMins()
{
return $this->travel_time_mins;
}
public function getTravelDistance()
{
return $this->travel_distance;
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = TechDistancesPeer::ID;
}
}
public function setTechId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->tech_id !== $v) {
$this->tech_id = $v;
$this->modifiedColumns[] = TechDistancesPeer::TECH_ID;
}
}
public function setClientId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->client_id !== $v) {
$this->client_id = $v;
$this->modifiedColumns[] = TechDistancesPeer::CLIENT_ID;
}
}
public function setTravelTimeHours($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->travel_time_hours !== $v) {
$this->travel_time_hours = $v;
$this->modifiedColumns[] = TechDistancesPeer::TRAVEL_TIME_HOURS;
}
}
public function setTravelTimeMins($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->travel_time_mins !== $v) {
$this->travel_time_mins = $v;
$this->modifiedColumns[] = TechDistancesPeer::TRAVEL_TIME_MINS;
}
}
public function setTravelDistance($v)
{
if ($this->travel_distance !== $v) {
$this->travel_distance = $v;
$this->modifiedColumns[] = TechDistancesPeer::TRAVEL_DISTANCE;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = TechDistancesPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->tech_id = $rs->getInt($startcol + 1);
$this->client_id = $rs->getInt($startcol + 2);
$this->travel_time_hours = $rs->getInt($startcol + 3);
$this->travel_time_mins = $rs->getInt($startcol + 4);
$this->travel_distance = $rs->getFloat($startcol + 5);
$this->updated_at = $rs->getTimestamp($startcol + 6, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 7;
} catch (Exception $e) {
throw new PropelException("Error populating TechDistances object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(TechDistancesPeer::DATABASE_NAME);
}
try {
$con->begin();
TechDistancesPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isModified() && !$this->isColumnModified(TechDistancesPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(TechDistancesPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = TechDistancesPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += TechDistancesPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = TechDistancesPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = TechDistancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getTechId();
break;
case 2:
return $this->getClientId();
break;
case 3:
return $this->getTravelTimeHours();
break;
case 4:
return $this->getTravelTimeMins();
break;
case 5:
return $this->getTravelDistance();
break;
case 6:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = TechDistancesPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getTechId(),
$keys[2] => $this->getClientId(),
$keys[3] => $this->getTravelTimeHours(),
$keys[4] => $this->getTravelTimeMins(),
$keys[5] => $this->getTravelDistance(),
$keys[6] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = TechDistancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setTechId($value);
break;
case 2:
$this->setClientId($value);
break;
case 3:
$this->setTravelTimeHours($value);
break;
case 4:
$this->setTravelTimeMins($value);
break;
case 5:
$this->setTravelDistance($value);
break;
case 6:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = TechDistancesPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setTechId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setClientId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setTravelTimeHours($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setTravelTimeMins($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setTravelDistance($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
}
public function buildCriteria()
{
$criteria = new Criteria(TechDistancesPeer::DATABASE_NAME);
if ($this->isColumnModified(TechDistancesPeer::ID)) $criteria->add(TechDistancesPeer::ID, $this->id);
if ($this->isColumnModified(TechDistancesPeer::TECH_ID)) $criteria->add(TechDistancesPeer::TECH_ID, $this->tech_id);
if ($this->isColumnModified(TechDistancesPeer::CLIENT_ID)) $criteria->add(TechDistancesPeer::CLIENT_ID, $this->client_id);
if ($this->isColumnModified(TechDistancesPeer::TRAVEL_TIME_HOURS)) $criteria->add(TechDistancesPeer::TRAVEL_TIME_HOURS, $this->travel_time_hours);
if ($this->isColumnModified(TechDistancesPeer::TRAVEL_TIME_MINS)) $criteria->add(TechDistancesPeer::TRAVEL_TIME_MINS, $this->travel_time_mins);
if ($this->isColumnModified(TechDistancesPeer::TRAVEL_DISTANCE)) $criteria->add(TechDistancesPeer::TRAVEL_DISTANCE, $this->travel_distance);
if ($this->isColumnModified(TechDistancesPeer::UPDATED_AT)) $criteria->add(TechDistancesPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(TechDistancesPeer::DATABASE_NAME);
$criteria->add(TechDistancesPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setTechId($this->tech_id);
$copyObj->setClientId($this->client_id);
$copyObj->setTravelTimeHours($this->travel_time_hours);
$copyObj->setTravelTimeMins($this->travel_time_mins);
$copyObj->setTravelDistance($this->travel_distance);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new TechDistancesPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,393 @@
<?php
abstract class BaseTechDistancesPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'tech_distances';
const CLASS_DEFAULT = 'lib.model.TechDistances';
const NUM_COLUMNS = 7;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'tech_distances.ID';
const TECH_ID = 'tech_distances.TECH_ID';
const CLIENT_ID = 'tech_distances.CLIENT_ID';
const TRAVEL_TIME_HOURS = 'tech_distances.TRAVEL_TIME_HOURS';
const TRAVEL_TIME_MINS = 'tech_distances.TRAVEL_TIME_MINS';
const TRAVEL_DISTANCE = 'tech_distances.TRAVEL_DISTANCE';
const UPDATED_AT = 'tech_distances.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'TechId', 'ClientId', 'TravelTimeHours', 'TravelTimeMins', 'TravelDistance', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (TechDistancesPeer::ID, TechDistancesPeer::TECH_ID, TechDistancesPeer::CLIENT_ID, TechDistancesPeer::TRAVEL_TIME_HOURS, TechDistancesPeer::TRAVEL_TIME_MINS, TechDistancesPeer::TRAVEL_DISTANCE, TechDistancesPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'tech_id', 'client_id', 'travel_time_hours', 'travel_time_mins', 'travel_distance', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TechId' => 1, 'ClientId' => 2, 'TravelTimeHours' => 3, 'TravelTimeMins' => 4, 'TravelDistance' => 5, 'UpdatedAt' => 6, ),
BasePeer::TYPE_COLNAME => array (TechDistancesPeer::ID => 0, TechDistancesPeer::TECH_ID => 1, TechDistancesPeer::CLIENT_ID => 2, TechDistancesPeer::TRAVEL_TIME_HOURS => 3, TechDistancesPeer::TRAVEL_TIME_MINS => 4, TechDistancesPeer::TRAVEL_DISTANCE => 5, TechDistancesPeer::UPDATED_AT => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tech_id' => 1, 'client_id' => 2, 'travel_time_hours' => 3, 'travel_time_mins' => 4, 'travel_distance' => 5, 'updated_at' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/TechDistancesMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.TechDistancesMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = TechDistancesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(TechDistancesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(TechDistancesPeer::ID);
$criteria->addSelectColumn(TechDistancesPeer::TECH_ID);
$criteria->addSelectColumn(TechDistancesPeer::CLIENT_ID);
$criteria->addSelectColumn(TechDistancesPeer::TRAVEL_TIME_HOURS);
$criteria->addSelectColumn(TechDistancesPeer::TRAVEL_TIME_MINS);
$criteria->addSelectColumn(TechDistancesPeer::TRAVEL_DISTANCE);
$criteria->addSelectColumn(TechDistancesPeer::UPDATED_AT);
}
const COUNT = 'COUNT(tech_distances.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT tech_distances.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(TechDistancesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(TechDistancesPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = TechDistancesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = TechDistancesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return TechDistancesPeer::populateObjects(TechDistancesPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
TechDistancesPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = TechDistancesPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return TechDistancesPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(TechDistancesPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(TechDistancesPeer::ID);
$selectCriteria->add(TechDistancesPeer::ID, $criteria->remove(TechDistancesPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(TechDistancesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(TechDistancesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof TechDistances) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(TechDistancesPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(TechDistances $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(TechDistancesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(TechDistancesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(TechDistancesPeer::DATABASE_NAME, TechDistancesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = TechDistancesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(TechDistancesPeer::DATABASE_NAME);
$criteria->add(TechDistancesPeer::ID, $pk);
$v = TechDistancesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(TechDistancesPeer::ID, $pks, Criteria::IN);
$objs = TechDistancesPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseTechDistancesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/TechDistancesMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.TechDistancesMapBuilder');
}

View File

@ -0,0 +1,479 @@
<?php
abstract class BaseUnprocessedDevices extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $filename;
protected $device_id;
protected $created_at;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getFilename()
{
return $this->filename;
}
public function getDeviceId()
{
return $this->device_id;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = UnprocessedDevicesPeer::ID;
}
}
public function setFilename($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->filename !== $v) {
$this->filename = $v;
$this->modifiedColumns[] = UnprocessedDevicesPeer::FILENAME;
}
}
public function setDeviceId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->device_id !== $v) {
$this->device_id = $v;
$this->modifiedColumns[] = UnprocessedDevicesPeer::DEVICE_ID;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = UnprocessedDevicesPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = UnprocessedDevicesPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->filename = $rs->getString($startcol + 1);
$this->device_id = $rs->getString($startcol + 2);
$this->created_at = $rs->getTimestamp($startcol + 3, null);
$this->updated_at = $rs->getTimestamp($startcol + 4, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating UnprocessedDevices object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(UnprocessedDevicesPeer::DATABASE_NAME);
}
try {
$con->begin();
UnprocessedDevicesPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(UnprocessedDevicesPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(UnprocessedDevicesPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(UnprocessedDevicesPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = UnprocessedDevicesPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += UnprocessedDevicesPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = UnprocessedDevicesPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UnprocessedDevicesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getFilename();
break;
case 2:
return $this->getDeviceId();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UnprocessedDevicesPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getFilename(),
$keys[2] => $this->getDeviceId(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UnprocessedDevicesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setFilename($value);
break;
case 2:
$this->setDeviceId($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UnprocessedDevicesPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setFilename($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDeviceId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(UnprocessedDevicesPeer::DATABASE_NAME);
if ($this->isColumnModified(UnprocessedDevicesPeer::ID)) $criteria->add(UnprocessedDevicesPeer::ID, $this->id);
if ($this->isColumnModified(UnprocessedDevicesPeer::FILENAME)) $criteria->add(UnprocessedDevicesPeer::FILENAME, $this->filename);
if ($this->isColumnModified(UnprocessedDevicesPeer::DEVICE_ID)) $criteria->add(UnprocessedDevicesPeer::DEVICE_ID, $this->device_id);
if ($this->isColumnModified(UnprocessedDevicesPeer::CREATED_AT)) $criteria->add(UnprocessedDevicesPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(UnprocessedDevicesPeer::UPDATED_AT)) $criteria->add(UnprocessedDevicesPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(UnprocessedDevicesPeer::DATABASE_NAME);
$criteria->add(UnprocessedDevicesPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setFilename($this->filename);
$copyObj->setDeviceId($this->device_id);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new UnprocessedDevicesPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,383 @@
<?php
abstract class BaseUnprocessedDevicesPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'unprocessed_devices';
const CLASS_DEFAULT = 'lib.model.UnprocessedDevices';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'unprocessed_devices.ID';
const FILENAME = 'unprocessed_devices.FILENAME';
const DEVICE_ID = 'unprocessed_devices.DEVICE_ID';
const CREATED_AT = 'unprocessed_devices.CREATED_AT';
const UPDATED_AT = 'unprocessed_devices.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Filename', 'DeviceId', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (UnprocessedDevicesPeer::ID, UnprocessedDevicesPeer::FILENAME, UnprocessedDevicesPeer::DEVICE_ID, UnprocessedDevicesPeer::CREATED_AT, UnprocessedDevicesPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'filename', 'device_id', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Filename' => 1, 'DeviceId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
BasePeer::TYPE_COLNAME => array (UnprocessedDevicesPeer::ID => 0, UnprocessedDevicesPeer::FILENAME => 1, UnprocessedDevicesPeer::DEVICE_ID => 2, UnprocessedDevicesPeer::CREATED_AT => 3, UnprocessedDevicesPeer::UPDATED_AT => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'filename' => 1, 'device_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/UnprocessedDevicesMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.UnprocessedDevicesMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = UnprocessedDevicesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(UnprocessedDevicesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(UnprocessedDevicesPeer::ID);
$criteria->addSelectColumn(UnprocessedDevicesPeer::FILENAME);
$criteria->addSelectColumn(UnprocessedDevicesPeer::DEVICE_ID);
$criteria->addSelectColumn(UnprocessedDevicesPeer::CREATED_AT);
$criteria->addSelectColumn(UnprocessedDevicesPeer::UPDATED_AT);
}
const COUNT = 'COUNT(unprocessed_devices.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT unprocessed_devices.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(UnprocessedDevicesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(UnprocessedDevicesPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = UnprocessedDevicesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = UnprocessedDevicesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return UnprocessedDevicesPeer::populateObjects(UnprocessedDevicesPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
UnprocessedDevicesPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = UnprocessedDevicesPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return UnprocessedDevicesPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(UnprocessedDevicesPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(UnprocessedDevicesPeer::ID);
$selectCriteria->add(UnprocessedDevicesPeer::ID, $criteria->remove(UnprocessedDevicesPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(UnprocessedDevicesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UnprocessedDevicesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof UnprocessedDevices) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(UnprocessedDevicesPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(UnprocessedDevices $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(UnprocessedDevicesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(UnprocessedDevicesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(UnprocessedDevicesPeer::DATABASE_NAME, UnprocessedDevicesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = UnprocessedDevicesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(UnprocessedDevicesPeer::DATABASE_NAME);
$criteria->add(UnprocessedDevicesPeer::ID, $pk);
$v = UnprocessedDevicesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(UnprocessedDevicesPeer::ID, $pks, Criteria::IN);
$objs = UnprocessedDevicesPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseUnprocessedDevicesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/UnprocessedDevicesMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.UnprocessedDevicesMapBuilder');
}

1239
lib/model/om/BaseUser.php Executable file

File diff suppressed because it is too large Load Diff

619
lib/model/om/BaseUserPeer.php Executable file
View File

@ -0,0 +1,619 @@
<?php
abstract class BaseUserPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'user';
const CLASS_DEFAULT = 'lib.model.User';
const NUM_COLUMNS = 20;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'user.ID';
const USER_NAME = 'user.USER_NAME';
const FIRST_NAME = 'user.FIRST_NAME';
const LAST_NAME = 'user.LAST_NAME';
const EMAIL = 'user.EMAIL';
const PHONE = 'user.PHONE';
const ADDRESS = 'user.ADDRESS';
const ADDRESS_2 = 'user.ADDRESS_2';
const CITY = 'user.CITY';
const STATE = 'user.STATE';
const ZIP = 'user.ZIP';
const PASSWORD = 'user.PASSWORD';
const START_TIME = 'user.START_TIME';
const END_TIME = 'user.END_TIME';
const LOCATION_ID = 'user.LOCATION_ID';
const CREATED_AT = 'user.CREATED_AT';
const UPDATED_AT = 'user.UPDATED_AT';
const USER_TYPE_ID = 'user.USER_TYPE_ID';
const WEIGHT = 'user.WEIGHT';
const ADMIN = 'user.ADMIN';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'UserName', 'FirstName', 'LastName', 'Email', 'Phone', 'Address', 'Address2', 'City', 'State', 'Zip', 'Password', 'StartTime', 'EndTime', 'LocationId', 'CreatedAt', 'UpdatedAt', 'UserTypeId', 'Weight', 'Admin', ),
BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::USER_NAME, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::PHONE, UserPeer::ADDRESS, UserPeer::ADDRESS_2, UserPeer::CITY, UserPeer::STATE, UserPeer::ZIP, UserPeer::PASSWORD, UserPeer::START_TIME, UserPeer::END_TIME, UserPeer::LOCATION_ID, UserPeer::CREATED_AT, UserPeer::UPDATED_AT, UserPeer::USER_TYPE_ID, UserPeer::WEIGHT, UserPeer::ADMIN, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'user_name', 'first_name', 'last_name', 'email', 'phone', 'address', 'address_2', 'city', 'state', 'zip', 'password', 'start_time', 'end_time', 'location_id', 'created_at', 'updated_at', 'user_type_id', 'weight', 'admin', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserName' => 1, 'FirstName' => 2, 'LastName' => 3, 'Email' => 4, 'Phone' => 5, 'Address' => 6, 'Address2' => 7, 'City' => 8, 'State' => 9, 'Zip' => 10, 'Password' => 11, 'StartTime' => 12, 'EndTime' => 13, 'LocationId' => 14, 'CreatedAt' => 15, 'UpdatedAt' => 16, 'UserTypeId' => 17, 'Weight' => 18, 'Admin' => 19, ),
BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::USER_NAME => 1, UserPeer::FIRST_NAME => 2, UserPeer::LAST_NAME => 3, UserPeer::EMAIL => 4, UserPeer::PHONE => 5, UserPeer::ADDRESS => 6, UserPeer::ADDRESS_2 => 7, UserPeer::CITY => 8, UserPeer::STATE => 9, UserPeer::ZIP => 10, UserPeer::PASSWORD => 11, UserPeer::START_TIME => 12, UserPeer::END_TIME => 13, UserPeer::LOCATION_ID => 14, UserPeer::CREATED_AT => 15, UserPeer::UPDATED_AT => 16, UserPeer::USER_TYPE_ID => 17, UserPeer::WEIGHT => 18, UserPeer::ADMIN => 19, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_name' => 1, 'first_name' => 2, 'last_name' => 3, 'email' => 4, 'phone' => 5, 'address' => 6, 'address_2' => 7, 'city' => 8, 'state' => 9, 'zip' => 10, 'password' => 11, 'start_time' => 12, 'end_time' => 13, 'location_id' => 14, 'created_at' => 15, 'updated_at' => 16, 'user_type_id' => 17, 'weight' => 18, 'admin' => 19, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/UserMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.UserMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = UserPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(UserPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(UserPeer::ID);
$criteria->addSelectColumn(UserPeer::USER_NAME);
$criteria->addSelectColumn(UserPeer::FIRST_NAME);
$criteria->addSelectColumn(UserPeer::LAST_NAME);
$criteria->addSelectColumn(UserPeer::EMAIL);
$criteria->addSelectColumn(UserPeer::PHONE);
$criteria->addSelectColumn(UserPeer::ADDRESS);
$criteria->addSelectColumn(UserPeer::ADDRESS_2);
$criteria->addSelectColumn(UserPeer::CITY);
$criteria->addSelectColumn(UserPeer::STATE);
$criteria->addSelectColumn(UserPeer::ZIP);
$criteria->addSelectColumn(UserPeer::PASSWORD);
$criteria->addSelectColumn(UserPeer::START_TIME);
$criteria->addSelectColumn(UserPeer::END_TIME);
$criteria->addSelectColumn(UserPeer::LOCATION_ID);
$criteria->addSelectColumn(UserPeer::CREATED_AT);
$criteria->addSelectColumn(UserPeer::UPDATED_AT);
$criteria->addSelectColumn(UserPeer::USER_TYPE_ID);
$criteria->addSelectColumn(UserPeer::WEIGHT);
$criteria->addSelectColumn(UserPeer::ADMIN);
}
const COUNT = 'COUNT(user.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT user.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(UserPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(UserPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = UserPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = UserPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return UserPeer::populateObjects(UserPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
UserPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = UserPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function doCountJoinUserType(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(UserPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(UserPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(UserPeer::USER_TYPE_ID, UserTypePeer::ID);
$rs = UserPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinUserType(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
UserPeer::addSelectColumns($c);
$startcol = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
UserTypePeer::addSelectColumns($c);
$c->addJoin(UserPeer::USER_TYPE_ID, UserTypePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = UserPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = UserTypePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$newObject = true;
foreach($results as $temp_obj1) {
$temp_obj2 = $temp_obj1->getUserType(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addUser($obj1); break;
}
}
if ($newObject) {
$obj2->initUsers();
$obj2->addUser($obj1); }
$results[] = $obj1;
}
return $results;
}
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(UserPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(UserPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(UserPeer::USER_TYPE_ID, UserTypePeer::ID);
$rs = UserPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
UserPeer::addSelectColumns($c);
$startcol2 = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
UserTypePeer::addSelectColumns($c);
$startcol3 = $startcol2 + UserTypePeer::NUM_COLUMNS;
$c->addJoin(UserPeer::USER_TYPE_ID, UserTypePeer::ID);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next()) {
$omClass = UserPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$omClass = UserTypePeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getUserType(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addUser($obj1); break;
}
}
if ($newObject) {
$obj2->initUsers();
$obj2->addUser($obj1);
}
$results[] = $obj1;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return UserPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(UserPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(UserPeer::ID);
$selectCriteria->add(UserPeer::ID, $criteria->remove(UserPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof User) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(UserPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(User $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(UserPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(UserPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(UserPeer::DATABASE_NAME, UserPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = UserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(UserPeer::DATABASE_NAME);
$criteria->add(UserPeer::ID, $pk);
$v = UserPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(UserPeer::ID, $pks, Criteria::IN);
$objs = UserPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseUserPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/UserMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.UserMapBuilder');
}

542
lib/model/om/BaseUserType.php Executable file
View File

@ -0,0 +1,542 @@
<?php
abstract class BaseUserType extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $type_name = '<null>';
protected $created_at;
protected $updated_at;
protected $collUsers;
protected $lastUserCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getTypeName()
{
return $this->type_name;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = UserTypePeer::ID;
}
}
public function setTypeName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->type_name !== $v || $v === '<null>') {
$this->type_name = $v;
$this->modifiedColumns[] = UserTypePeer::TYPE_NAME;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = UserTypePeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = UserTypePeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->type_name = $rs->getString($startcol + 1);
$this->created_at = $rs->getTimestamp($startcol + 2, null);
$this->updated_at = $rs->getTimestamp($startcol + 3, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 4;
} catch (Exception $e) {
throw new PropelException("Error populating UserType object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(UserTypePeer::DATABASE_NAME);
}
try {
$con->begin();
UserTypePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(UserTypePeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(UserTypePeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(UserTypePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = UserTypePeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += UserTypePeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collUsers !== null) {
foreach($this->collUsers as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = UserTypePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collUsers !== null) {
foreach($this->collUsers as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getTypeName();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserTypePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getTypeName(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setTypeName($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserTypePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setTypeName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
}
public function buildCriteria()
{
$criteria = new Criteria(UserTypePeer::DATABASE_NAME);
if ($this->isColumnModified(UserTypePeer::ID)) $criteria->add(UserTypePeer::ID, $this->id);
if ($this->isColumnModified(UserTypePeer::TYPE_NAME)) $criteria->add(UserTypePeer::TYPE_NAME, $this->type_name);
if ($this->isColumnModified(UserTypePeer::CREATED_AT)) $criteria->add(UserTypePeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(UserTypePeer::UPDATED_AT)) $criteria->add(UserTypePeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(UserTypePeer::DATABASE_NAME);
$criteria->add(UserTypePeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setTypeName($this->type_name);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getUsers() as $relObj) {
$copyObj->addUser($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new UserTypePeer();
}
return self::$peer;
}
public function initUsers()
{
if ($this->collUsers === null) {
$this->collUsers = array();
}
}
public function getUsers($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseUserPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collUsers === null) {
if ($this->isNew()) {
$this->collUsers = array();
} else {
$criteria->add(UserPeer::USER_TYPE_ID, $this->getId());
UserPeer::addSelectColumns($criteria);
$this->collUsers = UserPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(UserPeer::USER_TYPE_ID, $this->getId());
UserPeer::addSelectColumns($criteria);
if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) {
$this->collUsers = UserPeer::doSelect($criteria, $con);
}
}
}
$this->lastUserCriteria = $criteria;
return $this->collUsers;
}
public function countUsers($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseUserPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(UserPeer::USER_TYPE_ID, $this->getId());
return UserPeer::doCount($criteria, $distinct, $con);
}
public function addUser(User $l)
{
$this->collUsers[] = $l;
$l->setUserType($this);
}
}

378
lib/model/om/BaseUserTypePeer.php Executable file
View File

@ -0,0 +1,378 @@
<?php
abstract class BaseUserTypePeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'user_type';
const CLASS_DEFAULT = 'lib.model.UserType';
const NUM_COLUMNS = 4;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'user_type.ID';
const TYPE_NAME = 'user_type.TYPE_NAME';
const CREATED_AT = 'user_type.CREATED_AT';
const UPDATED_AT = 'user_type.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'TypeName', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (UserTypePeer::ID, UserTypePeer::TYPE_NAME, UserTypePeer::CREATED_AT, UserTypePeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'type_name', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TypeName' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
BasePeer::TYPE_COLNAME => array (UserTypePeer::ID => 0, UserTypePeer::TYPE_NAME => 1, UserTypePeer::CREATED_AT => 2, UserTypePeer::UPDATED_AT => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'type_name' => 1, 'created_at' => 2, 'updated_at' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/UserTypeMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.UserTypeMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = UserTypePeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(UserTypePeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(UserTypePeer::ID);
$criteria->addSelectColumn(UserTypePeer::TYPE_NAME);
$criteria->addSelectColumn(UserTypePeer::CREATED_AT);
$criteria->addSelectColumn(UserTypePeer::UPDATED_AT);
}
const COUNT = 'COUNT(user_type.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT user_type.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(UserTypePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(UserTypePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = UserTypePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = UserTypePeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return UserTypePeer::populateObjects(UserTypePeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
UserTypePeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = UserTypePeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return UserTypePeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(UserTypePeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(UserTypePeer::ID);
$selectCriteria->add(UserTypePeer::ID, $criteria->remove(UserTypePeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(UserTypePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserTypePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof UserType) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(UserTypePeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(UserType $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(UserTypePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(UserTypePeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(UserTypePeer::DATABASE_NAME, UserTypePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = UserTypePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(UserTypePeer::DATABASE_NAME);
$criteria->add(UserTypePeer::ID, $pk);
$v = UserTypePeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(UserTypePeer::ID, $pks, Criteria::IN);
$objs = UserTypePeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseUserTypePeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/UserTypeMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.UserTypeMapBuilder');
}

1569
lib/model/om/BaseWorkorder-.php Executable file

File diff suppressed because it is too large Load Diff

1739
lib/model/om/BaseWorkorder.php Executable file

File diff suppressed because it is too large Load Diff

1959
lib/model/om/BaseWorkorderPeer.php Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,479 @@
<?php
abstract class BaseWorkorderTech extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $workorder_id;
protected $user_id;
protected $created_at;
protected $updated_at;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getWorkorderId()
{
return $this->workorder_id;
}
public function getUserId()
{
return $this->user_id;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = WorkorderTechPeer::ID;
}
}
public function setWorkorderId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->workorder_id !== $v) {
$this->workorder_id = $v;
$this->modifiedColumns[] = WorkorderTechPeer::WORKORDER_ID;
}
}
public function setUserId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->user_id !== $v) {
$this->user_id = $v;
$this->modifiedColumns[] = WorkorderTechPeer::USER_ID;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = WorkorderTechPeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = WorkorderTechPeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->workorder_id = $rs->getInt($startcol + 1);
$this->user_id = $rs->getInt($startcol + 2);
$this->created_at = $rs->getTimestamp($startcol + 3, null);
$this->updated_at = $rs->getTimestamp($startcol + 4, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 5;
} catch (Exception $e) {
throw new PropelException("Error populating WorkorderTech object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(WorkorderTechPeer::DATABASE_NAME);
}
try {
$con->begin();
WorkorderTechPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(WorkorderTechPeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(WorkorderTechPeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(WorkorderTechPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = WorkorderTechPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += WorkorderTechPeer::doUpdate($this, $con);
}
$this->resetModified(); }
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = WorkorderTechPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = WorkorderTechPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getWorkorderId();
break;
case 2:
return $this->getUserId();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = WorkorderTechPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getWorkorderId(),
$keys[2] => $this->getUserId(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = WorkorderTechPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setWorkorderId($value);
break;
case 2:
$this->setUserId($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = WorkorderTechPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setWorkorderId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setUserId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
public function buildCriteria()
{
$criteria = new Criteria(WorkorderTechPeer::DATABASE_NAME);
if ($this->isColumnModified(WorkorderTechPeer::ID)) $criteria->add(WorkorderTechPeer::ID, $this->id);
if ($this->isColumnModified(WorkorderTechPeer::WORKORDER_ID)) $criteria->add(WorkorderTechPeer::WORKORDER_ID, $this->workorder_id);
if ($this->isColumnModified(WorkorderTechPeer::USER_ID)) $criteria->add(WorkorderTechPeer::USER_ID, $this->user_id);
if ($this->isColumnModified(WorkorderTechPeer::CREATED_AT)) $criteria->add(WorkorderTechPeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(WorkorderTechPeer::UPDATED_AT)) $criteria->add(WorkorderTechPeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(WorkorderTechPeer::DATABASE_NAME);
$criteria->add(WorkorderTechPeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setWorkorderId($this->workorder_id);
$copyObj->setUserId($this->user_id);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new WorkorderTechPeer();
}
return self::$peer;
}
}

View File

@ -0,0 +1,383 @@
<?php
abstract class BaseWorkorderTechPeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'workorder_tech';
const CLASS_DEFAULT = 'lib.model.WorkorderTech';
const NUM_COLUMNS = 5;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'workorder_tech.ID';
const WORKORDER_ID = 'workorder_tech.WORKORDER_ID';
const USER_ID = 'workorder_tech.USER_ID';
const CREATED_AT = 'workorder_tech.CREATED_AT';
const UPDATED_AT = 'workorder_tech.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'WorkorderId', 'UserId', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (WorkorderTechPeer::ID, WorkorderTechPeer::WORKORDER_ID, WorkorderTechPeer::USER_ID, WorkorderTechPeer::CREATED_AT, WorkorderTechPeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'workorder_id', 'user_id', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'WorkorderId' => 1, 'UserId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
BasePeer::TYPE_COLNAME => array (WorkorderTechPeer::ID => 0, WorkorderTechPeer::WORKORDER_ID => 1, WorkorderTechPeer::USER_ID => 2, WorkorderTechPeer::CREATED_AT => 3, WorkorderTechPeer::UPDATED_AT => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'workorder_id' => 1, 'user_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/WorkorderTechMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.WorkorderTechMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = WorkorderTechPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(WorkorderTechPeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(WorkorderTechPeer::ID);
$criteria->addSelectColumn(WorkorderTechPeer::WORKORDER_ID);
$criteria->addSelectColumn(WorkorderTechPeer::USER_ID);
$criteria->addSelectColumn(WorkorderTechPeer::CREATED_AT);
$criteria->addSelectColumn(WorkorderTechPeer::UPDATED_AT);
}
const COUNT = 'COUNT(workorder_tech.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT workorder_tech.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(WorkorderTechPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(WorkorderTechPeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = WorkorderTechPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = WorkorderTechPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return WorkorderTechPeer::populateObjects(WorkorderTechPeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
WorkorderTechPeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = WorkorderTechPeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return WorkorderTechPeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(WorkorderTechPeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(WorkorderTechPeer::ID);
$selectCriteria->add(WorkorderTechPeer::ID, $criteria->remove(WorkorderTechPeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(WorkorderTechPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(WorkorderTechPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof WorkorderTech) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(WorkorderTechPeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(WorkorderTech $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(WorkorderTechPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(WorkorderTechPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(WorkorderTechPeer::DATABASE_NAME, WorkorderTechPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = WorkorderTechPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(WorkorderTechPeer::DATABASE_NAME);
$criteria->add(WorkorderTechPeer::ID, $pk);
$v = WorkorderTechPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(WorkorderTechPeer::ID, $pks, Criteria::IN);
$objs = WorkorderTechPeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseWorkorderTechPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/WorkorderTechMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.WorkorderTechMapBuilder');
}

View File

@ -0,0 +1,682 @@
<?php
abstract class BaseWorkorderType extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $type_name = '<null>';
protected $created_at;
protected $updated_at;
protected $collWorkorders;
protected $lastWorkorderCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getTypeName()
{
return $this->type_name;
}
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function getUpdatedAt($format = 'Y-m-d H:i:s')
{
if ($this->updated_at === null || $this->updated_at === '') {
return null;
} elseif (!is_int($this->updated_at)) {
$ts = strtotime($this->updated_at);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
}
} else {
$ts = $this->updated_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = WorkorderTypePeer::ID;
}
}
public function setTypeName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->type_name !== $v || $v === '<null>') {
$this->type_name = $v;
$this->modifiedColumns[] = WorkorderTypePeer::TYPE_NAME;
}
}
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = WorkorderTypePeer::CREATED_AT;
}
}
public function setUpdatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->updated_at !== $ts) {
$this->updated_at = $ts;
$this->modifiedColumns[] = WorkorderTypePeer::UPDATED_AT;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->type_name = $rs->getString($startcol + 1);
$this->created_at = $rs->getTimestamp($startcol + 2, null);
$this->updated_at = $rs->getTimestamp($startcol + 3, null);
$this->resetModified();
$this->setNew(false);
return $startcol + 4;
} catch (Exception $e) {
throw new PropelException("Error populating WorkorderType object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(WorkorderTypePeer::DATABASE_NAME);
}
try {
$con->begin();
WorkorderTypePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isNew() && !$this->isColumnModified(WorkorderTypePeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($this->isModified() && !$this->isColumnModified(WorkorderTypePeer::UPDATED_AT))
{
$this->setUpdatedAt(time());
}
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(WorkorderTypePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = WorkorderTypePeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += WorkorderTypePeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
protected $validationFailures = array();
public function getValidationFailures()
{
return $this->validationFailures;
}
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = WorkorderTypePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collWorkorders !== null) {
foreach($this->collWorkorders as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = WorkorderTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getTypeName();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = WorkorderTypePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getTypeName(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = WorkorderTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setTypeName($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = WorkorderTypePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setTypeName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
}
public function buildCriteria()
{
$criteria = new Criteria(WorkorderTypePeer::DATABASE_NAME);
if ($this->isColumnModified(WorkorderTypePeer::ID)) $criteria->add(WorkorderTypePeer::ID, $this->id);
if ($this->isColumnModified(WorkorderTypePeer::TYPE_NAME)) $criteria->add(WorkorderTypePeer::TYPE_NAME, $this->type_name);
if ($this->isColumnModified(WorkorderTypePeer::CREATED_AT)) $criteria->add(WorkorderTypePeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(WorkorderTypePeer::UPDATED_AT)) $criteria->add(WorkorderTypePeer::UPDATED_AT, $this->updated_at);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(WorkorderTypePeer::DATABASE_NAME);
$criteria->add(WorkorderTypePeer::ID, $this->id);
return $criteria;
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($key)
{
$this->setId($key);
}
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setTypeName($this->type_name);
$copyObj->setCreatedAt($this->created_at);
$copyObj->setUpdatedAt($this->updated_at);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getWorkorders() as $relObj) {
$copyObj->addWorkorder($relObj->copy($deepCopy));
}
}
$copyObj->setNew(true);
$copyObj->setId(NULL);
}
public function copy($deepCopy = false)
{
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new WorkorderTypePeer();
}
return self::$peer;
}
public function initWorkorders()
{
if ($this->collWorkorders === null) {
$this->collWorkorders = array();
}
}
public function getWorkorders($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
WorkorderPeer::addSelectColumns($criteria);
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelect($criteria, $con);
}
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function countWorkorders($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
return WorkorderPeer::doCount($criteria, $distinct, $con);
}
public function addWorkorder(Workorder $l)
{
$this->collWorkorders[] = $l;
$l->setWorkorderType($this);
}
public function getWorkordersJoinDevice($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinDevice($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinClient($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinClient($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinJobStatus($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinJobStatus($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinJobStatus($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
public function getWorkordersJoinJobType($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseWorkorderPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collWorkorders === null) {
if ($this->isNew()) {
$this->collWorkorders = array();
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
$this->collWorkorders = WorkorderPeer::doSelectJoinJobType($criteria, $con);
}
} else {
$criteria->add(WorkorderPeer::WORKORDER_TYPE_ID, $this->getId());
if (!isset($this->lastWorkorderCriteria) || !$this->lastWorkorderCriteria->equals($criteria)) {
$this->collWorkorders = WorkorderPeer::doSelectJoinJobType($criteria, $con);
}
}
$this->lastWorkorderCriteria = $criteria;
return $this->collWorkorders;
}
}

View File

@ -0,0 +1,378 @@
<?php
abstract class BaseWorkorderTypePeer {
const DATABASE_NAME = 'propel';
const TABLE_NAME = 'workorder_type';
const CLASS_DEFAULT = 'lib.model.WorkorderType';
const NUM_COLUMNS = 4;
const NUM_LAZY_LOAD_COLUMNS = 0;
const ID = 'workorder_type.ID';
const TYPE_NAME = 'workorder_type.TYPE_NAME';
const CREATED_AT = 'workorder_type.CREATED_AT';
const UPDATED_AT = 'workorder_type.UPDATED_AT';
private static $phpNameMap = null;
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'TypeName', 'CreatedAt', 'UpdatedAt', ),
BasePeer::TYPE_COLNAME => array (WorkorderTypePeer::ID, WorkorderTypePeer::TYPE_NAME, WorkorderTypePeer::CREATED_AT, WorkorderTypePeer::UPDATED_AT, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'type_name', 'created_at', 'updated_at', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TypeName' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
BasePeer::TYPE_COLNAME => array (WorkorderTypePeer::ID => 0, WorkorderTypePeer::TYPE_NAME => 1, WorkorderTypePeer::CREATED_AT => 2, WorkorderTypePeer::UPDATED_AT => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'type_name' => 1, 'created_at' => 2, 'updated_at' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
public static function getMapBuilder()
{
include_once 'lib/model/map/WorkorderTypeMapBuilder.php';
return BasePeer::getMapBuilder('lib.model.map.WorkorderTypeMapBuilder');
}
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = WorkorderTypePeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
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.');
}
return self::$fieldNames[$type];
}
public static function alias($alias, $column)
{
return str_replace(WorkorderTypePeer::TABLE_NAME.'.', $alias.'.', $column);
}
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(WorkorderTypePeer::ID);
$criteria->addSelectColumn(WorkorderTypePeer::TYPE_NAME);
$criteria->addSelectColumn(WorkorderTypePeer::CREATED_AT);
$criteria->addSelectColumn(WorkorderTypePeer::UPDATED_AT);
}
const COUNT = 'COUNT(workorder_type.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT workorder_type.ID)';
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(WorkorderTypePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(WorkorderTypePeer::COUNT);
}
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = WorkorderTypePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
return 0;
}
}
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = WorkorderTypePeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
public static function doSelect(Criteria $criteria, $con = null)
{
return WorkorderTypePeer::populateObjects(WorkorderTypePeer::doSelectRS($criteria, $con));
}
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
WorkorderTypePeer::addSelectColumns($criteria);
}
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doSelect($criteria, $con);
}
public static function populateObjects(ResultSet $rs)
{
$results = array();
$cls = WorkorderTypePeer::getOMClass();
$cls = Propel::import($cls);
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
public static function getOMClass()
{
return WorkorderTypePeer::CLASS_DEFAULT;
}
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } else {
$criteria = $values->buildCriteria(); }
$criteria->remove(WorkorderTypePeer::ID);
$criteria->setDbName(self::DATABASE_NAME);
try {
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(WorkorderTypePeer::ID);
$selectCriteria->add(WorkorderTypePeer::ID, $criteria->remove(WorkorderTypePeer::ID), $comparison);
} else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; try {
$con->begin();
$affectedRows += BasePeer::doDeleteAll(WorkorderTypePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(WorkorderTypePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; } elseif ($values instanceof WorkorderType) {
$criteria = $values->buildPkeyCriteria();
} else {
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(WorkorderTypePeer::ID, (array) $values, Criteria::IN);
}
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
try {
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public static function doValidate(WorkorderType $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(WorkorderTypePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(WorkorderTypePeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(WorkorderTypePeer::DATABASE_NAME, WorkorderTypePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = WorkorderTypePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(WorkorderTypePeer::DATABASE_NAME);
$criteria->add(WorkorderTypePeer::ID, $pk);
$v = WorkorderTypePeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(WorkorderTypePeer::ID, $pks, Criteria::IN);
$objs = WorkorderTypePeer::doSelect($criteria, $con);
}
return $objs;
}
}
if (Propel::isInit()) {
try {
BaseWorkorderTypePeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
require_once 'lib/model/map/WorkorderTypeMapBuilder.php';
Propel::registerMapBuilder('lib.model.map.WorkorderTypeMapBuilder');
}