Beispiel #1
0
 private function _getNextValue($sequence = 'admin')
 {
     $transaction = $this->db->beginTransaction();
     $table = $this->db->getConfig('sequence.table');
     $name = $this->db->getConfig('sequence.name');
     $field = $this->db->getConfig('sequence.value');
     $sql = new \Maestro\Database\MSQL($field, $table, "({$name} = '{$sequence}')");
     $sql->setForUpdate(true);
     $result = $this->db->query($sql);
     $value = \Manager::getOptions('fetchStyle') == \FETCH_NUM ? $result[0][0] : $result[0][$field];
     $nextValue = $value + 1;
     $this->db->execute($sql->update($nextValue), $nextValue);
     $transaction->commit();
     return $value;
 }