Files
luos/workflow/engine/classes/model/AppSequence.php
Ronald Q 8b466dd855 HOR-669 CLONE - Sequence generator locks APPLICATION table
HOR-669 CLONE - Sequence generator locks APPLICATION table

up observations

fix in insert
2016-04-04 12:50:58 -04:00

65 lines
1.7 KiB
PHP

<?php
require_once 'classes/model/om/BaseAppSequence.php';
/**
* Skeleton subclass for representing a row from the 'APP_SEQUENCE' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class AppSequence extends BaseAppSequence {
/**
* Get an Set new sequence number
*
* @return mixed
* @throws Exception
*/
public function sequenceNumber()
{
try {
$con = Propel::getConnection('workflow');
$stmt = $con->createStatement();
//UPDATE SEQUENCES SET SEQ_VALUE = LAST_INSERT_ID(SEQ_VALUE + 1);
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID(ID+1)";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
//SELECT LAST_INSERT_ID()
$sql = "SELECT LAST_INSERT_ID()";
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
$result = $row['LAST_INSERT_ID()'];
} catch (\Exception $e) {
throw ($e);
}
return $result;
}
/**
* Update sequence number
*
* @return mixed
* @throws Exception
*/
public function updateSequenceNumber($number)
{
try {
$con = Propel::getConnection('workflow');
$stmt = $con->createStatement();
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID('$number')";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
} catch (\Exception $e) {
throw ($e);
}
}
} // AppSequence