Rev 1364 | Rev 1370 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1364 | Rev 1365 | ||
---|---|---|---|
Line 59... | Line 59... | ||
59 | } else if (is_null($arg)) { |
59 | } else if (is_null($arg)) { |
60 | $replace = 'NULL'; |
60 | $replace = 'NULL'; |
61 | } else { |
61 | } else { |
62 | // TODO: More types? |
62 | // TODO: More types? |
63 | if ($this->slangDetectionDone) { |
63 | if ($this->slangDetectionDone) { |
64 | $replace = "'".$this->getSlang()->escapeString($arg)."'"; |
64 | $replace = "N'".$this->getSlang()->escapeString($arg)."'"; |
65 | } else { |
65 | } else { |
66 | $replace = "'".str_replace("'", "''", $arg)."'"; |
66 | $replace = "N'".str_replace("'", "''", $arg)."'"; |
67 | } |
67 | } |
68 | } |
68 | } |
69 | $pos = strpos($sql, $needle); |
69 | $pos = strpos($sql, $needle); |
70 | if ($pos !== false) { |
70 | if ($pos !== false) { |
71 | $sql = substr_replace($sql, $replace, $pos, strlen($needle)); |
71 | $sql = substr_replace($sql, $replace, $pos, strlen($needle)); |
Line 97... | Line 97... | ||
97 | $this->last_error = null; |
97 | $this->last_error = null; |
98 | if (is_null($prepared_args)) { |
98 | if (is_null($prepared_args)) { |
99 | try { |
99 | try { |
100 | $fetchableRowsExpected = $this->slangDetectionDone ? $this->getSlang()->fetchableRowsExpected($sql) : str_starts_with(trim(strtolower($sql)),'select'); |
100 | $fetchableRowsExpected = $this->slangDetectionDone ? $this->getSlang()->fetchableRowsExpected($sql) : str_starts_with(trim(strtolower($sql)),'select'); |
101 | if ($fetchableRowsExpected) { |
101 | if ($fetchableRowsExpected) { |
102 | $res = new \COM("ADODB.Recordset"); |
102 | $res = new \COM("ADODB.Recordset", NULL, 65001/*CP_UTF8*/); |
103 | 103 | ||
104 | $res->Open($sql, $this->conn, 3/*adOpenStatic*/, 3/*adLockOptimistic*/); /** @phpstan-ignore-line */ |
104 | $res->Open($sql, $this->conn, 3/*adOpenStatic*/, 3/*adLockOptimistic*/); /** @phpstan-ignore-line */ |
105 | 105 | ||
106 | $deb = new OIDplusQueryResultADO($res); |
106 | $deb = new OIDplusQueryResultADO($res); |
107 | 107 | ||
Line 120... | Line 120... | ||
120 | 120 | ||
121 | return $deb; |
121 | return $deb; |
122 | 122 | ||
123 | } else { |
123 | } else { |
124 | $this->conn->Execute($sql, $this->rowsAffected); |
124 | $this->conn->Execute($sql, $this->rowsAffected); |
- | 125 | ||
- | 126 | // Alternatively: |
|
- | 127 | //$cmd = new \COM("ADODB.Command", NULL, 65001/*CP_UTF8*/); |
|
- | 128 | //$cmd->CommandText = $sql; |
|
- | 129 | //$cmd->CommandType = 1/*adCmdText*/; |
|
- | 130 | //$cmd->ActiveConnection = $this->conn; |
|
- | 131 | //$cmd->Execute(); |
|
- | 132 | ||
125 | return new OIDplusQueryResultADO(null); |
133 | return new OIDplusQueryResultADO(null); |
126 | } |
134 | } |
127 | } catch (\Exception $e) { |
135 | } catch (\Exception $e) { |
128 | $this->last_error = $e->getMessage(); |
136 | $this->last_error = $e->getMessage(); |
129 | throw new OIDplusSQLException($sql, $this->error()); |
137 | throw new OIDplusSQLException($sql, $this->error()); |