Files
luos/workflow/engine/classes/model/LoginLog.php

131 lines
3.8 KiB
PHP
Raw Normal View History

2010-12-02 23:34:41 +00:00
<?php
2011-01-31 14:14:55 +00:00
/**
* LoginLog.php
*
* @package workflow.engine.classes.model
2011-01-31 14:14:55 +00:00
*/
2010-12-02 23:34:41 +00:00
require_once 'classes/model/om/BaseLoginLog.php';
/**
* Skeleton subclass for representing a row from the 'LOGIN_LOG' table.
*
*
2010-12-02 23:34:41 +00:00
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
2010-12-02 23:34:41 +00:00
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
2010-12-02 23:34:41 +00:00
*/
class LoginLog extends BaseLoginLog
{
function create ($aData)
2010-12-02 23:34:41 +00:00
{
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
try {
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$result = $this->save();
} else {
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $this->getValidationFailures();
throw ($e);
}
$con->commit();
return $result;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
2010-12-02 23:34:41 +00:00
}
public function load ($LogUid)
2010-12-02 23:34:41 +00:00
{
try {
$oRow = LoginLogPeer::retrieveByPK( $LogUid );
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
} else {
throw (new Exception( "The row '" . $LogUid . "' in table LOGIN_LOG doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
2010-12-02 23:34:41 +00:00
}
public function update ($fields)
2010-12-02 23:34:41 +00:00
{
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
try {
$con->begin();
$this->load( $fields['LOG_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
2010-12-02 23:34:41 +00:00
}
function remove ($LogUid)
2010-12-02 23:34:41 +00:00
{
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
try {
$con->begin();
$this->setWlUid( $LogUid );
$result = $this->delete();
$con->commit();
return $result;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
2010-12-02 23:34:41 +00:00
}
//Added by Qennix
function getLastLoginByUser ($sUID)
2010-12-02 23:34:41 +00:00
{
$c = new Criteria();
$c->addSelectColumn( LoginLogPeer::LOG_INIT_DATE );
$c->add( LoginLogPeer::USR_UID, $sUID );
$c->setLimit( 1 );
$c->addDescendingOrderByColumn( LoginLogPeer::LOG_INIT_DATE );
$Dat = LoginLogPeer::doSelectRS( $c );
$Dat->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$Dat->next();
$aRow = $Dat->getRow();
return isset( $aRow['LOG_INIT_DATE'] ) ? $aRow['LOG_INIT_DATE'] : '';
2010-12-02 23:34:41 +00:00
}
//Added by Qennix
function getLastLoginAllUsers ()
2010-12-02 23:34:41 +00:00
{
$c = new Criteria();
$c->addSelectColumn( LoginLogPeer::USR_UID );
$c->addAsColumn( 'LAST_LOGIN', 'MAX(LOG_INIT_DATE)' );
$c->addGroupByColumn( LoginLogPeer::USR_UID );
$Dat = LoginLogPeer::doSelectRS( $c );
$Dat->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aRows = Array ();
while ($Dat->next()) {
$row = $Dat->getRow();
$aRows[$row['USR_UID']] = $row['LAST_LOGIN'];
}
return $aRows;
2010-12-02 23:34:41 +00:00
}
}
// LoginLog