Spaces:
Sleeping
Sleeping
File size: 2,109 Bytes
07c3cdd | 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <?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();
$c = new Criteria();
$rs = AppSequencePeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
if ($row) {
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID('$number')";
} else {
$sql = "INSERT INTO APP_SEQUENCE (ID) VALUES ('$number');";
}
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
} catch (\Exception $e) {
throw ($e);
}
}
} // AppSequence
|