|
18 | 18 |
|
19 | 19 | #if FB_API_VER >= 40 |
20 | 20 |
|
21 | | -#include "pdo_firebird_utils.h" |
22 | 21 | #include <firebird/Interface.h> |
23 | 22 | #include <cstring> |
| 23 | +#include "php.h" |
| 24 | +#include "pdo_firebird_utils.h" |
| 25 | +#include "php_ibase_includes.h" |
24 | 26 |
|
25 | 27 | /* Returns the client version. 0 bytes are minor version, 1 bytes are major version. */ |
26 | 28 | extern "C" unsigned fb_get_client_version(void) |
@@ -81,24 +83,38 @@ extern "C" void fb_decode_timestamp_tz(const ISC_TIMESTAMP_TZ* timestampTz, |
81 | 83 | timeZoneBufferLength, timeZoneBuffer); |
82 | 84 | } |
83 | 85 |
|
84 | | -extern "C" int fb_get_sql_info(ISC_STATUS* st, isc_stmt_handle* stmt, |
85 | | - unsigned itemsLength, const unsigned char* items, |
86 | | - unsigned bufferLength, unsigned char* buffer) |
| 86 | +extern "C" int fb_insert_aliases(ISC_STATUS* st, ibase_query *ib_query) |
87 | 87 | { |
88 | 88 | Firebird::IMaster* master = Firebird::fb_get_master_interface(); |
89 | 89 | Firebird::ThrowStatusWrapper status(master->getStatus()); |
90 | 90 | Firebird::IStatement* statement = NULL; |
| 91 | + Firebird::IMessageMetadata* meta = NULL; |
| 92 | + ISC_STATUS res; |
91 | 93 |
|
92 | | - if (fb_get_statement_interface(st, &statement, stmt)){ |
93 | | - // if (sv[0] == 1 && sv[1] > 0) |
94 | | - return st[1]; |
| 94 | + if (res = fb_get_statement_interface(st, &statement, &ib_query->stmt)){ |
| 95 | + return res; |
95 | 96 | } |
96 | 97 |
|
97 | | - // TODO: check status; |
98 | | - statement->getInfo(&status, itemsLength, items, bufferLength, buffer); |
| 98 | + try { |
| 99 | + meta = statement->getOutputMetadata(&status); |
| 100 | + unsigned cols = meta->getCount(&status); |
99 | 101 |
|
100 | | - statement->release(); |
101 | | - statement = NULL; |
| 102 | + assert(cols == ib_query->out_fields_count); |
| 103 | + |
| 104 | + zval t; |
| 105 | + for (unsigned i = 0; i < cols; ++i) |
| 106 | + { |
| 107 | + _php_ibase_insert_alias(ib_query->ht_aliases, |
| 108 | + meta->getAlias(&status, i), strlen(meta->getAlias(&status, i))); |
| 109 | + } |
| 110 | + } |
| 111 | + catch (const Firebird::FbException& error) |
| 112 | + { |
| 113 | + if (status.hasData()) { |
| 114 | + fb_copy_status((const ISC_STATUS*)status.getErrors(), st, 20); |
| 115 | + return st[1]; |
| 116 | + } |
| 117 | + } |
102 | 118 |
|
103 | 119 | return 0; |
104 | 120 | } |
|
0 commit comments