PMCORE-2364
This commit is contained in:
@@ -53,26 +53,36 @@ class AppSequence extends BaseAppSequence {
|
||||
/**
|
||||
* Update sequence number
|
||||
*
|
||||
* @return mixed
|
||||
* @param int $number
|
||||
* @param string $sequenceType
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateSequenceNumber($number)
|
||||
public function updateSequenceNumber($number, $sequenceType = AppSequence::APP_TYPE_NORMAL)
|
||||
{
|
||||
try {
|
||||
$con = Propel::getConnection('workflow');
|
||||
$stmt = $con->createStatement();
|
||||
$c = new Criteria();
|
||||
$rs = AppSequencePeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
// Get the current connection
|
||||
$connection = Propel::getConnection('workflow');
|
||||
|
||||
// Create a statement instance
|
||||
$statement = $connection->createStatement();
|
||||
|
||||
// Get the record according to the sequence type
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(AppSequencePeer::APP_TYPE, $sequenceType);
|
||||
$rsCriteria = AppSequencePeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
// Insert/Update sequence table with the number sent
|
||||
if ($row) {
|
||||
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID('$number')";
|
||||
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID('{$number}') WHERE APP_TYPE = '{$sequenceType}'";
|
||||
} else {
|
||||
$sql = "INSERT INTO APP_SEQUENCE (ID) VALUES ('$number');";
|
||||
$sql = "INSERT INTO APP_SEQUENCE (ID, APP_TYPE) VALUES ('{$number}', '{$sequenceType}')";
|
||||
}
|
||||
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
} catch (\Exception $e) {
|
||||
$statement->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
} catch (Exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class AppSequenceMapBuilder
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
$tMap->addColumn('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('APP_TYPE', 'AppType', 'string', CreoleTypes::VARCHAR, true, 20);
|
||||
|
||||
|
||||
@@ -480,30 +480,33 @@ abstract class BaseAppSequence extends BaseObject implements Persistent
|
||||
{
|
||||
$criteria = new Criteria(AppSequencePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(AppSequencePeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
* Returns NULL since this table doesn't have a primary key.
|
||||
* This method exists only for BC and is deprecated!
|
||||
* @return null
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
* Dummy primary key setter.
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
* This function only exists to preserve backwards compatibility. It is no longer
|
||||
* needed or required by the Persistent interface. It will be removed in next BC-breaking
|
||||
* release of Propel.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
public function setPrimaryKey($pk)
|
||||
{
|
||||
// do nothing, because this object doesn't have any primary keys
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
@@ -518,13 +521,13 @@ abstract class BaseAppSequence extends BaseObject implements Persistent
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setId($this->id);
|
||||
|
||||
$copyObj->setAppType($this->app_type);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -171,8 +171,8 @@ abstract class BaseAppSequencePeer
|
||||
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(APP_SEQUENCE.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT APP_SEQUENCE.ID)';
|
||||
const COUNT = 'COUNT(*)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT *)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
@@ -381,9 +381,6 @@ abstract class BaseAppSequencePeer
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(AppSequencePeer::ID);
|
||||
$selectCriteria->add(AppSequencePeer::ID, $criteria->remove(AppSequencePeer::ID), $comparison);
|
||||
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
@@ -441,11 +438,22 @@ abstract class BaseAppSequencePeer
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof AppSequence) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
$criteria = $values->buildCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(AppSequencePeer::ID, (array) $values, Criteria::IN);
|
||||
// primary key is composite; we therefore, expect
|
||||
// the primary key passed to be an array of pkey
|
||||
// values
|
||||
if (count($values) == count($values, COUNT_RECURSIVE)) {
|
||||
// array is not multi-dimensional
|
||||
$values = array($values);
|
||||
}
|
||||
$vals = array();
|
||||
foreach ($values as $value) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
@@ -503,54 +511,6 @@ abstract class BaseAppSequencePeer
|
||||
|
||||
return BasePeer::doValidate(AppSequencePeer::DATABASE_NAME, AppSequencePeer::TABLE_NAME, $columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return AppSequence
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(AppSequencePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(AppSequencePeer::ID, $pk);
|
||||
|
||||
|
||||
$v = AppSequencePeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
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(AppSequencePeer::ID, $pks, Criteria::IN);
|
||||
$objs = AppSequencePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user