Bug fix for DB\IO returning detection
it was still coded with old one line and not taking in possible line breaks in the returning code part
This commit is contained in:
@@ -413,13 +413,35 @@ if (is_array($s_res = $db->dbReturnRow($q)) && !empty($s_res['test'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UPDATE WITH RETURNING
|
// UPDATE WITH RETURNING
|
||||||
$status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT' "
|
$status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT', string_a = '" . (string)rand(1, 100) . "' "
|
||||||
. "WHERE test_foo_id = " . (int)$last_insert_pk . " RETURNING test");
|
. "WHERE test_foo_id = " . (int)$last_insert_pk . " RETURNING test_foo.test, string_a");
|
||||||
print "UPDATE WITH PK " . Support::printToString($last_insert_pk)
|
print "UPDATE WITH PK " . Support::printToString($last_insert_pk)
|
||||||
. " RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
. " RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||||
|
// UPDATE BUT EOM STYLE
|
||||||
|
$status = $db->dbExecParams(
|
||||||
|
<<<EOM
|
||||||
|
UPDATE
|
||||||
|
test_foo
|
||||||
|
SET
|
||||||
|
test = ?,
|
||||||
|
string_a = ?
|
||||||
|
WHERE
|
||||||
|
tset_foo_id = ?
|
||||||
|
RETURNING
|
||||||
|
test_foo.test, string_a
|
||||||
|
EOM,
|
||||||
|
['SOMETHING DIFFERENT EOM', (string)rand(1, 100)]
|
||||||
|
);
|
||||||
|
print "UPDATE EOM WITH PK " . Support::printToString($last_insert_pk)
|
||||||
|
. " RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||||
|
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||||
|
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||||
|
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||||
|
|
||||||
|
// a stand alone insert?
|
||||||
$db->dbExec("INSERT INTO test_foo (test) VALUES ('STAND ALONE')");
|
$db->dbExec("INSERT INTO test_foo (test) VALUES ('STAND ALONE')");
|
||||||
|
|
||||||
// INSERT WITH NO RETURNING
|
// INSERT WITH NO RETURNING
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ class IO
|
|||||||
/** @var string default hash type */
|
/** @var string default hash type */
|
||||||
public const ERROR_HASH_TYPE = 'adler32';
|
public const ERROR_HASH_TYPE = 'adler32';
|
||||||
/** @var string regex to get returning with matches at position 1 */
|
/** @var string regex to get returning with matches at position 1 */
|
||||||
public const REGEX_RETURNING = '/\s+returning\s+(.+?);?$/i';
|
public const REGEX_RETURNING = '/\s+returning\s+(.+\s*(?:.+\s*)+);?$/i';
|
||||||
|
|
||||||
// recommend to set private/protected and only allow setting via method
|
// recommend to set private/protected and only allow setting via method
|
||||||
// can bet set from outside
|
// can bet set from outside
|
||||||
|
|||||||
Reference in New Issue
Block a user