mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding patch from Ticket #2176, extracts the sequence name from the default value for the primary key and returns it's last value
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4572 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f05ab47e94
commit
b3b1c80a69
1 changed files with 7 additions and 1 deletions
|
@ -357,7 +357,13 @@ class DboPostgres extends DboSource {
|
|||
return null;
|
||||
}
|
||||
|
||||
$sql = "SELECT last_value AS max FROM \"{$source}_{$field}_seq\"";
|
||||
if (preg_match('/^nextval\(\'(\w+)\'/', $sourceinfo['default'], $matches)) {
|
||||
$seq = $matches[1];
|
||||
} else {
|
||||
$seq = "{$source}_{$field}_seq";
|
||||
}
|
||||
$sql = "SELECT last_value AS max FROM \"{$seq}\"";
|
||||
|
||||
$res = $this->rawQuery($sql);
|
||||
$data = $this->fetchRow($res);
|
||||
return $data[0]['max'];
|
||||
|
|
Loading…
Reference in a new issue