|
|
|
|
@@ -266,16 +266,18 @@ class IO
|
|
|
|
|
// 1: read new, keep at end, clean before new run
|
|
|
|
|
// 2: read new, clean at the end (temporary cache)
|
|
|
|
|
// 3: never cache
|
|
|
|
|
/** @var int */
|
|
|
|
|
/** @var int use cache (default) in dbReturn */
|
|
|
|
|
public const USE_CACHE = 0;
|
|
|
|
|
/** @var int */
|
|
|
|
|
/** @var int reset cache and read new in dbReturn */
|
|
|
|
|
public const READ_NEW = 1;
|
|
|
|
|
/** @var int */
|
|
|
|
|
/** @var int clear cache after read in dbeEturn */
|
|
|
|
|
public const CLEAR_CACHE = 2;
|
|
|
|
|
/** @var int */
|
|
|
|
|
/** @var int do not use any cache in dbReturn */
|
|
|
|
|
public const NO_CACHE = 3;
|
|
|
|
|
/** @var string */
|
|
|
|
|
/** @var string default hash type */
|
|
|
|
|
public const ERROR_HASH_TYPE = 'adler32';
|
|
|
|
|
/** @var string regex to get returning with matches at position 1 */
|
|
|
|
|
public const REGEX_RETURNING = '/\s?returning(?: (.+?));?$/i';
|
|
|
|
|
|
|
|
|
|
// recommend to set private/protected and only allow setting via method
|
|
|
|
|
// can bet set from outside
|
|
|
|
|
@@ -1007,7 +1009,7 @@ class IO
|
|
|
|
|
$this->pk_name_table[$table] : 'NULL';
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
!preg_match("/\s?returning /i", $this->query) &&
|
|
|
|
|
!preg_match(self::REGEX_RETURNING, $this->query) &&
|
|
|
|
|
$this->pk_name && $this->pk_name != 'NULL'
|
|
|
|
|
) {
|
|
|
|
|
// check if this query has a ; at the end and remove it
|
|
|
|
|
@@ -1016,7 +1018,9 @@ class IO
|
|
|
|
|
$this->query = !is_string($__query) ? $this->query : $__query;
|
|
|
|
|
$this->query .= " RETURNING " . $this->pk_name;
|
|
|
|
|
$this->returning_id = true;
|
|
|
|
|
} elseif (preg_match("/\s?returning (.*)/i", $this->query, $matches)) {
|
|
|
|
|
} elseif (
|
|
|
|
|
preg_match(self::REGEX_RETURNING, $this->query, $matches)
|
|
|
|
|
) {
|
|
|
|
|
if ($this->pk_name && $this->pk_name != 'NULL') {
|
|
|
|
|
// add the primary key if it is not in the returning set
|
|
|
|
|
if (!preg_match("/$this->pk_name/", $matches[1])) {
|
|
|
|
|
@@ -1030,7 +1034,7 @@ class IO
|
|
|
|
|
// if we have an UPDATE and RETURNING, flag for true, but do not add anything
|
|
|
|
|
if (
|
|
|
|
|
$this->__checkQueryForUpdate($this->query) &&
|
|
|
|
|
preg_match("/\s?returning (.*)/i", $this->query, $matches)
|
|
|
|
|
preg_match(self::REGEX_RETURNING, $this->query, $matches)
|
|
|
|
|
) {
|
|
|
|
|
$this->returning_id = true;
|
|
|
|
|
}
|
|
|
|
|
@@ -2288,11 +2292,14 @@ class IO
|
|
|
|
|
$this->prepare_cursor[$stm_name]['pk_name'] = $pk_name;
|
|
|
|
|
}
|
|
|
|
|
// if no returning, then add it
|
|
|
|
|
if (!preg_match("/\s?returning /i", $query) && $this->prepare_cursor[$stm_name]['pk_name']) {
|
|
|
|
|
if (
|
|
|
|
|
!preg_match(self::REGEX_RETURNING, $query) &&
|
|
|
|
|
$this->prepare_cursor[$stm_name]['pk_name']
|
|
|
|
|
) {
|
|
|
|
|
$query .= " RETURNING " . $this->prepare_cursor[$stm_name]['pk_name'];
|
|
|
|
|
$this->prepare_cursor[$stm_name]['returning_id'] = true;
|
|
|
|
|
} elseif (
|
|
|
|
|
preg_match("/\s?returning (.*)/i", $query, $matches) &&
|
|
|
|
|
preg_match(self::REGEX_RETURNING, $query, $matches) &&
|
|
|
|
|
$this->prepare_cursor[$stm_name]['pk_name']
|
|
|
|
|
) {
|
|
|
|
|
// if returning exists but not pk_name, add it
|
|
|
|
|
|