Rev 1370 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1370 | Rev 1453 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | * @var bool |
38 | * @var bool |
39 | */ |
39 | */ |
40 | private $transactions_supported = false; |
40 | private $transactions_supported = false; |
41 | 41 | ||
42 | /** |
42 | /** |
- | 43 | * @var |
|
- | 44 | */ |
|
- | 45 | private $prepare_cache = []; |
|
- | 46 | ||
- | 47 | /** |
|
43 | * @param string $sql |
48 | * @param string $sql |
44 | * @param array|null $prepared_args |
49 | * @param array|null $prepared_args |
45 | * @return OIDplusQueryResultPDO |
50 | * @return OIDplusQueryResultPDO |
46 | * @throws OIDplusException |
51 | * @throws OIDplusException |
47 | */ |
52 | */ |
Line 71... | Line 76... | ||
71 | } |
76 | } |
72 | } |
77 | } |
73 | } |
78 | } |
74 | unset($value); |
79 | unset($value); |
75 | 80 | ||
- | 81 | if (isset($this->prepare_cache[$sql])) { |
|
- | 82 | // Attention: Caching prepared statements in PDO and ODBC is risky, |
|
- | 83 | // because it seems that existing pointers are destroyed |
|
- | 84 | // when execeute() is called. |
|
- | 85 | // However, since we always fetch all data (to allow MARS), |
|
- | 86 | // the testcase "Simultanous prepared statements" works, so we should be fine...? |
|
- | 87 | $ps = $this->prepare_cache[$sql]; |
|
- | 88 | } else { |
|
76 | $ps = $this->conn->prepare($sql); |
89 | $ps = $this->conn->prepare($sql); |
- | 90 | if (!$ps) $ps = false; // because null will result in isset()=false |
|
- | 91 | $this->prepare_cache[$sql] = $ps; |
|
- | 92 | } |
|
77 | if (!$ps) { |
93 | if (!$ps) { |
78 | $this->last_error = $this->conn->errorInfo()[2]; |
94 | $this->last_error = $this->conn->errorInfo()[2]; |
79 | if (!$this->last_error) $this->last_error = _L("Error")." ".$this->conn->errorInfo()[0]; // if no message is available, only show the error-code |
95 | if (!$this->last_error) $this->last_error = _L("Error")." ".$this->conn->errorInfo()[0]; // if no message is available, only show the error-code |
80 | throw new OIDplusSQLException($sql, _L('Cannot prepare statement').': '.$this->error()); |
96 | throw new OIDplusSQLException($sql, _L('Cannot prepare statement').': '.$this->error()); |
81 | } |
97 | } |