/trunk/plugins/viathinksoft/database/oci/OIDplusDatabaseConnectionOci.class.php |
---|
66,7 → 66,7 |
return ":param$i"; |
}, $sql, count($prepared_args), $count); |
$res = @oci_parse($this->conn, $sql); |
$res = @oci_parse($this->conn, $sql); // TODO: prepare_cache (is this safe?) |
if ($res === false) { |
$this->last_error = oci_error($this->conn); |
throw new OIDplusSQLException($sql, _L('Cannot prepare statement').': '.$this->error()); |
/trunk/plugins/viathinksoft/database/odbc/OIDplusQueryResultODBC.class.php |
---|
42,6 → 42,10 |
if (!$this->no_resultset) { |
$this->res = $res; |
// Since caching prepared statements will cause the testcase "Simultanous prepared statements" to fail, |
// this will fix it. |
$this->prefetchAll(); |
} |
} |
99,10 → 103,21 |
} |
/** |
* Goes to the last result set (in case a query returns multiple result sets) |
* @return void |
*/ |
protected function gotoLastResultSet() { |
while (@odbc_next_result($this->res)) { |
// Do nothing |
} |
} |
/** |
* @return array|null |
*/ |
protected function do_fetch_array()/*: ?array*/ { |
$ret = odbc_fetch_array($this->res); |
//$this->gotoLastResultSet(); // TODO: This causes problems (read dbms_version on null) |
$ret = @odbc_fetch_array($this->res); |
if ($ret === false) $ret = null; |
return $ret; |
} |
111,7 → 126,8 |
* @return object|null |
*/ |
protected function do_fetch_object()/*: ?object*/ { |
$ret = odbc_fetch_object($this->res); |
//$this->gotoLastResultSet(); // TODO: This causes problems (read dbms_version on null) |
$ret = @odbc_fetch_object($this->res); |
if ($ret === false) $ret = null; |
return $ret; |
} |
/trunk/plugins/viathinksoft/database/pdo/OIDplusDatabaseConnectionPDO.class.php |
---|
40,6 → 40,11 |
private $transactions_supported = false; |
/** |
* @var |
*/ |
private $prepare_cache = []; |
/** |
* @param string $sql |
* @param array|null $prepared_args |
* @return OIDplusQueryResultPDO |
73,7 → 78,18 |
} |
unset($value); |
if (isset($this->prepare_cache[$sql])) { |
// Attention: Caching prepared statements in PDO and ODBC is risky, |
// because it seems that existing pointers are destroyed |
// when execeute() is called. |
// However, since we always fetch all data (to allow MARS), |
// the testcase "Simultanous prepared statements" works, so we should be fine...? |
$ps = $this->prepare_cache[$sql]; |
} else { |
$ps = $this->conn->prepare($sql); |
if (!$ps) $ps = false; // because null will result in isset()=false |
$this->prepare_cache[$sql] = $ps; |
} |
if (!$ps) { |
$this->last_error = $this->conn->errorInfo()[2]; |
if (!$this->last_error) $this->last_error = _L("Error")." ".$this->conn->errorInfo()[0]; // if no message is available, only show the error-code |