1 /* Copyright (c) 2000 Adam Kropielnicki
2 See the file COPYING for more information */
3
4 // Some versions of PHP 7.0 need INT64_MIN/INT64_MAX to be defined but
5 // these gyrations are necessary when using C++.
6 #include <rudiments/private/config.h>
7 #ifdef RUDIMENTS_HAVE_STDINT_H
8 #define __STDC_LIMIT_MACROS
9 #include <stdint.h>
10 #endif
11
12 #include <sqlrelay/sqlrclient.h>
13
14 // The various define/undef games below play havoc with inttypes.h
15 // on some platforms (openbsd 5.7, for example). Including it here
16 // prevents it from being included later after the games.
17 // We'll borrow a macro from rudiments to detect it's existence.
18 #ifdef RUDIMENTS_HAVE_INTTYPES_H
19 #include <inttypes.h>
20 #endif
21
22 #ifdef WIN32
23 #undef uid_t
24 #undef gid_t
25 #undef ssize_t
26 #undef socklen_t
27 #undef pid_t
28 #undef mode_t
29 #define PHP_WIN32
30 #define ZEND_WIN32
31 #define ZEND_DEBUG 0
32 #define ZTS 1
33 #endif
34
35 extern "C" {
36 #ifndef WIN32
37
38 // On some platforms (solaris), stdio.h must be included prior
39 // to including math.h or FILE will get redefined.
40 #include <stdio.h>
41
42 // php.h ultimately includes math.h and on some platforms,
43 // __cplusplus to be defined when including it. Manually
44 // including it prior to including php.h solves this problem.
45 #include <math.h>
46
47 #ifdef __cplusplus
48 #undef __cplusplus
49 #define cpluspluswasdefined
50 #endif
51 #ifndef HAVE_SOCKLEN_T
52 #define HAVE_SOCKLEN_T
53 #endif
54 #ifndef _WCHAR_T_DECLARED
55 #define _WCHAR_T_DECLARED
56 #endif
57 #ifndef _WCHAR_T_DEFINED_
58 #define _WCHAR_T_DEFINED_
59 #endif
60 #endif
61 #include <php.h>
62 #ifndef WIN32
63 #ifdef cpluspluswasdefined
64 #define __cplusplus
65 #endif
66 #endif
67 }
68
69 #include <config.h>
70
71 #if PHP_MAJOR_VERSION >= 7
72
73 #define ZVAL zval*
74
75 #define zend_rsrc_list_entry zend_resource
76 #define ZEND_REGISTER_RESOURCE(a,b,c) \
77 RETURN_RES(zend_register_resource(b,c))
78 #define ZEND_FETCH_RESOURCE(a,b,c,d,e,f) \
79 if ((a=(b)zend_fetch_resource( \
80 Z_RES_P((zval *)c),e,f))==NULL) { \
81 RETURN_FALSE; \
82 }
83 #define ZEND_LIST_DELETE(a) zend_list_delete(Z_RES_P(a));
84
85 #define GET_PARAMETERS zend_parse_parameters
86 #define PARAMS(a) a,
87
88 #define SVAL(a) Z_STRVAL_P(a)
89 #define LVAL(a) Z_LVAL_P(a)
90 #define DVAL(a) Z_DVAL_P(a)
91 #define ARRVAL(a) Z_ARRVAL_P(a)
92 #define TYPE(a) Z_TYPE_P(a)
93
94 #define RET_STRING(a,b) \
95 RETURN_STR(zend_string_init(a,charstring::length(a),0))
96 #define RET_STRINGL(a,b,c) \
97 RETURN_STR(zend_string_init(a,b,0))
98
99
100 #define ADD_ASSOC_STRINGL(a,b,c,d,e) \
101 add_assoc_stringl(a,b,zend_string_init(c,d,0)->val,d)
102 #define ADD_NEXT_INDEX_STRING(a,b,c) \
103 add_next_index_string( \
104 a,zend_string_init(b,charstring::length(b),0)->val)
105 #define ADD_NEXT_INDEX_STRINGL(a,b,c,d) \
106 add_next_index_stringl(a,zend_string_init(b,c,0)->val,c)
107
108 #define HASH_INDEX_FIND(a,b,c) c=zend_hash_index_find(a,b)
109
110 #if PHP_MAJOR_VERSION > 7 || PHP_MINOR_VERSION > 2
111 #define ARRAY_INIT_CANT_FAIL 1
112 #endif
113
114 #if PHP_MAJOR_VERSION > 7 || PHP_MINOR_VERSION < 4
115 #define ADD_ASSOC_NULL(a,b) add_assoc_unset(a,b)
116 #define ADD_NEXT_INDEX_NULL(a) add_next_index_unset(a)
117 #else
118 #define ADD_ASSOC_NULL(a,b) add_assoc_null(a,b)
119 #define ADD_NEXT_INDEX_NULL(a) add_next_index_null(a)
120 #endif
121
122 #else
123
124 #define ZVAL zval**
125
126 #define ZEND_LIST_DELETE(a) zend_list_delete(LVAL(a));
127
128 #define GET_PARAMETERS zend_get_parameters_ex
129 #define PARAMS(a)
130
131 // apparently, sufficiently old PHP doesn't support Z_*VAL(a)...
132 #define SVAL(a) (*a)->value.str.val
133 #define LVAL(a) (*a)->value.lval
134 #define DVAL(a) (*a)->value.dval
135 #define ARRVAL(a) (*a)->value.ht
136 #define TYPE(a) Z_TYPE_PP(a)
137
138 #define RET_STRING RETURN_STRING
139 #define RET_STRINGL RETURN_STRINGL
140
141 #define ADD_ASSOC_STRINGL(a,b,c,d,e) add_assoc_stringl(a,b,c,d,e)
142 #define ADD_ASSOC_NULL(a,b) add_assoc_unset(a,b)
143 #define ADD_NEXT_INDEX_STRING(a,b,c) add_next_index_string(a,b,c)
144 #define ADD_NEXT_INDEX_STRINGL(a,b,c,d) add_next_index_stringl(a,b,c,d)
145 #define ADD_NEXT_INDEX_NULL(a) add_next_index_unset(a)
146
147 #define HASH_INDEX_FIND(a,b,c) zend_hash_index_find(a,b,(void **)&c)
148 #endif
149
150 // old enough versions of PHP don't support TSRMLS macros
151 #ifndef TSRMLS_DC
152 #define TSRMLS_DC
153 #endif
154 #ifndef TSRMLS_CC
155 #define TSRMLS_CC
156 #endif
157
158 extern "C" {
159
160 #ifdef _WIN32
161 #include <windows.h>
162 #define DLEXPORT __declspec(dllexport)
163 #else
164 #define DLEXPORT
165 #endif
166
167 static int sqlrelay_connection;
168 static int sqlrelay_cursor;
169
170 #ifdef ZEND_MODULE_STARTUP_D
sqlrcon_cleanup(zend_rsrc_list_entry * rsrc TSRMLS_DC)171 static void sqlrcon_cleanup(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
172 sqlrconnection *connection=(sqlrconnection *)rsrc->ptr;
173 delete connection;
174 }
175
sqlrcur_cleanup(zend_rsrc_list_entry * rsrc TSRMLS_DC)176 static void sqlrcur_cleanup(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
177 sqlrcursor *cursor=(sqlrcursor *)rsrc->ptr;
178 delete cursor;
179 }
180
ZEND_MODULE_STARTUP_D(sqlrelay)181 ZEND_MODULE_STARTUP_D(sqlrelay) {
182 sqlrelay_connection=zend_register_list_destructors_ex(sqlrcon_cleanup,
183 NULL,"sqlrelay connection",module_number);
184 sqlrelay_cursor=zend_register_list_destructors_ex(sqlrcur_cleanup,
185 NULL,"sqlrelay cursor",module_number);
186 return SUCCESS;
187 }
188 #endif
189
ZEND_FUNCTION(sqlrcon_alloc)190 DLEXPORT ZEND_FUNCTION(sqlrcon_alloc) {
191 ZVAL server;
192 ZVAL port;
193 ZVAL socket;
194 ZVAL user;
195 ZVAL password;
196 ZVAL retrytime;
197 ZVAL tries;
198 sqlrconnection *connection=NULL;
199 if (ZEND_NUM_ARGS() != 7 ||
200 GET_PARAMETERS(
201 ZEND_NUM_ARGS() TSRMLS_CC,
202 PARAMS("zzzzzzz")
203 &server,
204 &port,
205 &socket,
206 &user,
207 &password,
208 &retrytime,
209 &tries) == FAILURE) {
210 WRONG_PARAM_COUNT;
211 }
212 convert_to_string_ex(server);
213 convert_to_long_ex(port);
214 convert_to_string_ex(socket);
215 convert_to_string_ex(user);
216 convert_to_string_ex(password);
217 convert_to_long_ex(retrytime);
218 convert_to_long_ex(tries);
219 connection=new sqlrconnection(
220 SVAL(server),
221 LVAL(port),
222 SVAL(socket),
223 SVAL(user),
224 SVAL(password),
225 LVAL(retrytime),
226 LVAL(tries),
227 true);
228 connection->debugPrintFunction((int (*)(const char *,...))zend_printf);
229 ZEND_REGISTER_RESOURCE(return_value,connection,sqlrelay_connection);
230 }
231
ZEND_FUNCTION(sqlrcon_free)232 DLEXPORT ZEND_FUNCTION(sqlrcon_free) {
233 ZVAL sqlrcon;
234 if (ZEND_NUM_ARGS() != 1 ||
235 GET_PARAMETERS(
236 ZEND_NUM_ARGS() TSRMLS_CC,
237 PARAMS("z")
238 &sqlrcon) == FAILURE) {
239 WRONG_PARAM_COUNT;
240 }
241 sqlrconnection *connection=NULL;
242 ZEND_FETCH_RESOURCE(connection,
243 sqlrconnection *,
244 sqlrcon,
245 -1,
246 "sqlrelay connection",
247 sqlrelay_connection);
248 ZEND_LIST_DELETE(sqlrcon);
249 }
250
ZEND_FUNCTION(sqlrcon_setconnecttimeout)251 DLEXPORT ZEND_FUNCTION(sqlrcon_setconnecttimeout) {
252 ZVAL sqlrcon;
253 ZVAL timeoutsec;
254 ZVAL timeoutusec;
255 if (ZEND_NUM_ARGS() != 3 ||
256 GET_PARAMETERS(
257 ZEND_NUM_ARGS() TSRMLS_CC,
258 PARAMS("zzz")
259 &sqlrcon,
260 &timeoutsec,
261 &timeoutusec) == FAILURE) {
262 WRONG_PARAM_COUNT;
263 }
264 convert_to_long_ex(timeoutsec);
265 convert_to_long_ex(timeoutusec);
266 sqlrconnection *connection=NULL;
267 ZEND_FETCH_RESOURCE(connection,
268 sqlrconnection *,
269 sqlrcon,
270 -1,
271 "sqlrelay connection",
272 sqlrelay_connection);
273 if (connection) {
274 connection->setConnectTimeout(LVAL(timeoutsec),
275 LVAL(timeoutusec));
276 }
277 }
278
ZEND_FUNCTION(sqlrcon_setauthenticationtimeout)279 DLEXPORT ZEND_FUNCTION(sqlrcon_setauthenticationtimeout) {
280 ZVAL sqlrcon;
281 ZVAL timeoutsec;
282 ZVAL timeoutusec;
283 if (ZEND_NUM_ARGS() != 3 ||
284 GET_PARAMETERS(
285 ZEND_NUM_ARGS() TSRMLS_CC,
286 PARAMS("zzz")
287 &sqlrcon,
288 &timeoutsec,
289 &timeoutusec) == FAILURE) {
290 WRONG_PARAM_COUNT;
291 }
292 convert_to_long_ex(timeoutsec);
293 convert_to_long_ex(timeoutusec);
294 sqlrconnection *connection=NULL;
295 ZEND_FETCH_RESOURCE(connection,
296 sqlrconnection *,
297 sqlrcon,
298 -1,
299 "sqlrelay connection",
300 sqlrelay_connection);
301 if (connection) {
302 connection->setAuthenticationTimeout(LVAL(timeoutsec),
303 LVAL(timeoutusec));
304 }
305 }
306
ZEND_FUNCTION(sqlrcon_setresponsetimeout)307 DLEXPORT ZEND_FUNCTION(sqlrcon_setresponsetimeout) {
308 ZVAL sqlrcon;
309 ZVAL timeoutsec;
310 ZVAL timeoutusec;
311 if (ZEND_NUM_ARGS() != 3 ||
312 GET_PARAMETERS(
313 ZEND_NUM_ARGS() TSRMLS_CC,
314 PARAMS("zzz")
315 &sqlrcon,
316 &timeoutsec,
317 &timeoutusec) == FAILURE) {
318 WRONG_PARAM_COUNT;
319 }
320 convert_to_long_ex(timeoutsec);
321 convert_to_long_ex(timeoutusec);
322 sqlrconnection *connection=NULL;
323 ZEND_FETCH_RESOURCE(connection,
324 sqlrconnection *,
325 sqlrcon,
326 -1,
327 "sqlrelay connection",
328 sqlrelay_connection);
329 if (connection) {
330 connection->setResponseTimeout(LVAL(timeoutsec),
331 LVAL(timeoutusec));
332 }
333 }
334
ZEND_FUNCTION(sqlrcon_setbindvariabledelimiters)335 DLEXPORT ZEND_FUNCTION(sqlrcon_setbindvariabledelimiters) {
336 ZVAL sqlrcon;
337 ZVAL delimiters;
338 if (ZEND_NUM_ARGS() != 2 ||
339 GET_PARAMETERS(
340 ZEND_NUM_ARGS() TSRMLS_CC,
341 PARAMS("zz")
342 &sqlrcon,
343 &delimiters) == FAILURE) {
344 WRONG_PARAM_COUNT;
345 }
346 convert_to_string_ex(delimiters);
347 sqlrconnection *connection=NULL;
348 ZEND_FETCH_RESOURCE(connection,
349 sqlrconnection *,
350 sqlrcon,
351 -1,
352 "sqlrelay connection",
353 sqlrelay_connection);
354 if (connection) {
355 connection->setBindVariableDelimiters(SVAL(delimiters));
356 }
357 }
358
ZEND_FUNCTION(sqlrcon_getbindvariabledelimiterquestionmarksupported)359 DLEXPORT ZEND_FUNCTION(sqlrcon_getbindvariabledelimiterquestionmarksupported) {
360 ZVAL sqlrcon;
361 bool r;
362 if (ZEND_NUM_ARGS() != 2 ||
363 GET_PARAMETERS(
364 ZEND_NUM_ARGS() TSRMLS_CC,
365 PARAMS("z")
366 &sqlrcon) == FAILURE) {
367 WRONG_PARAM_COUNT;
368 }
369 sqlrconnection *connection=NULL;
370 ZEND_FETCH_RESOURCE(connection,
371 sqlrconnection *,
372 sqlrcon,
373 -1,
374 "sqlrelay connection",
375 sqlrelay_connection);
376 if (connection) {
377 r=connection->getBindVariableDelimiterQuestionMarkSupported();
378 RETURN_LONG(r);
379 }
380 RETURN_LONG(0);
381 }
382
ZEND_FUNCTION(sqlrcon_getbindvariabledelimitercolonsupported)383 DLEXPORT ZEND_FUNCTION(sqlrcon_getbindvariabledelimitercolonsupported) {
384 ZVAL sqlrcon;
385 bool r;
386 if (ZEND_NUM_ARGS() != 2 ||
387 GET_PARAMETERS(
388 ZEND_NUM_ARGS() TSRMLS_CC,
389 PARAMS("z")
390 &sqlrcon) == FAILURE) {
391 WRONG_PARAM_COUNT;
392 }
393 sqlrconnection *connection=NULL;
394 ZEND_FETCH_RESOURCE(connection,
395 sqlrconnection *,
396 sqlrcon,
397 -1,
398 "sqlrelay connection",
399 sqlrelay_connection);
400 if (connection) {
401 r=connection->getBindVariableDelimiterColonSupported();
402 RETURN_LONG(r);
403 }
404 RETURN_LONG(0);
405 }
406
ZEND_FUNCTION(sqlrcon_getbindvariabledelimiteratsignsupported)407 DLEXPORT ZEND_FUNCTION(sqlrcon_getbindvariabledelimiteratsignsupported) {
408 ZVAL sqlrcon;
409 bool r;
410 if (ZEND_NUM_ARGS() != 2 ||
411 GET_PARAMETERS(
412 ZEND_NUM_ARGS() TSRMLS_CC,
413 PARAMS("z")
414 &sqlrcon) == FAILURE) {
415 WRONG_PARAM_COUNT;
416 }
417 sqlrconnection *connection=NULL;
418 ZEND_FETCH_RESOURCE(connection,
419 sqlrconnection *,
420 sqlrcon,
421 -1,
422 "sqlrelay connection",
423 sqlrelay_connection);
424 if (connection) {
425 r=connection->getBindVariableDelimiterAtSignSupported();
426 RETURN_LONG(r);
427 }
428 RETURN_LONG(0);
429 }
430
ZEND_FUNCTION(sqlrcon_getbindvariabledelimiterdollarsignsupported)431 DLEXPORT ZEND_FUNCTION(sqlrcon_getbindvariabledelimiterdollarsignsupported) {
432 ZVAL sqlrcon;
433 bool r;
434 if (ZEND_NUM_ARGS() != 2 ||
435 GET_PARAMETERS(
436 ZEND_NUM_ARGS() TSRMLS_CC,
437 PARAMS("z")
438 &sqlrcon) == FAILURE) {
439 WRONG_PARAM_COUNT;
440 }
441 sqlrconnection *connection=NULL;
442 ZEND_FETCH_RESOURCE(connection,
443 sqlrconnection *,
444 sqlrcon,
445 -1,
446 "sqlrelay connection",
447 sqlrelay_connection);
448 if (connection) {
449 r=connection->getBindVariableDelimiterDollarSignSupported();
450 RETURN_LONG(r);
451 }
452 RETURN_LONG(0);
453 }
454
ZEND_FUNCTION(sqlrcon_enablekerberos)455 DLEXPORT ZEND_FUNCTION(sqlrcon_enablekerberos) {
456 ZVAL sqlrcon;
457 ZVAL service;
458 ZVAL mech;
459 ZVAL flags;
460 if (ZEND_NUM_ARGS() != 4 ||
461 GET_PARAMETERS(
462 ZEND_NUM_ARGS() TSRMLS_CC,
463 PARAMS("zzzz")
464 &sqlrcon,
465 &service,
466 &mech,
467 &flags) == FAILURE) {
468 WRONG_PARAM_COUNT;
469 }
470 convert_to_string_ex(service);
471 convert_to_string_ex(mech);
472 convert_to_string_ex(flags);
473 sqlrconnection *connection=NULL;
474 ZEND_FETCH_RESOURCE(connection,
475 sqlrconnection *,
476 sqlrcon,
477 -1,
478 "sqlrelay connection",
479 sqlrelay_connection);
480 if (connection) {
481 connection->enableKerberos(SVAL(service),
482 SVAL(mech),
483 SVAL(flags));
484 }
485 }
486
ZEND_FUNCTION(sqlrcon_enabletls)487 DLEXPORT ZEND_FUNCTION(sqlrcon_enabletls) {
488 ZVAL sqlrcon;
489 ZVAL version;
490 ZVAL cert;
491 ZVAL password;
492 ZVAL ciphers;
493 ZVAL validate;
494 ZVAL ca;
495 ZVAL depth;
496 if (ZEND_NUM_ARGS() != 8 ||
497 GET_PARAMETERS(
498 ZEND_NUM_ARGS() TSRMLS_CC,
499 PARAMS("zzzzzzzz")
500 &sqlrcon,
501 &version,
502 &cert,
503 &password,
504 &ciphers,
505 &validate,
506 &ca,
507 &depth) == FAILURE) {
508 WRONG_PARAM_COUNT;
509 }
510 convert_to_string_ex(version);
511 convert_to_string_ex(cert);
512 convert_to_string_ex(password);
513 convert_to_string_ex(ciphers);
514 convert_to_string_ex(validate);
515 convert_to_string_ex(ca);
516 convert_to_long_ex(depth);
517 sqlrconnection *connection=NULL;
518 ZEND_FETCH_RESOURCE(connection,
519 sqlrconnection *,
520 sqlrcon,
521 -1,
522 "sqlrelay connection",
523 sqlrelay_connection);
524 if (connection) {
525 connection->enableTls(SVAL(version),
526 SVAL(cert),
527 SVAL(password),
528 SVAL(ciphers),
529 SVAL(validate),
530 SVAL(ca),
531 LVAL(depth));
532 }
533 }
534
ZEND_FUNCTION(sqlrcon_disableencryption)535 DLEXPORT ZEND_FUNCTION(sqlrcon_disableencryption) {
536 ZVAL sqlrcon;
537 if (ZEND_NUM_ARGS() != 1 ||
538 GET_PARAMETERS(
539 ZEND_NUM_ARGS() TSRMLS_CC,
540 PARAMS("z")
541 &sqlrcon) == FAILURE) {
542 WRONG_PARAM_COUNT;
543 }
544 sqlrconnection *connection=NULL;
545 ZEND_FETCH_RESOURCE(connection,
546 sqlrconnection *,
547 sqlrcon,
548 -1,
549 "sqlrelay connection",
550 sqlrelay_connection);
551 if (connection) {
552 connection->disableEncryption();
553 }
554 }
555
ZEND_FUNCTION(sqlrcon_endsession)556 DLEXPORT ZEND_FUNCTION(sqlrcon_endsession) {
557 ZVAL sqlrcon;
558 if (ZEND_NUM_ARGS() != 1 ||
559 GET_PARAMETERS(
560 ZEND_NUM_ARGS() TSRMLS_CC,
561 PARAMS("z")
562 &sqlrcon) == FAILURE) {
563 WRONG_PARAM_COUNT;
564 }
565 sqlrconnection *connection=NULL;
566 ZEND_FETCH_RESOURCE(connection,
567 sqlrconnection *,
568 sqlrcon,
569 -1,
570 "sqlrelay connection",
571 sqlrelay_connection);
572 if (connection) {
573 connection->endSession();
574 }
575 }
576
ZEND_FUNCTION(sqlrcon_suspendsession)577 DLEXPORT ZEND_FUNCTION(sqlrcon_suspendsession) {
578 ZVAL sqlrcon;
579 bool r;
580 if (ZEND_NUM_ARGS() != 1 ||
581 GET_PARAMETERS(
582 ZEND_NUM_ARGS() TSRMLS_CC,
583 PARAMS("z")
584 &sqlrcon) == FAILURE) {
585 WRONG_PARAM_COUNT;
586 }
587 sqlrconnection *connection=NULL;
588 ZEND_FETCH_RESOURCE(connection,
589 sqlrconnection *,
590 sqlrcon,
591 -1,
592 "sqlrelay connection",
593 sqlrelay_connection);
594 if (connection) {
595 r=connection->suspendSession();
596 RETURN_LONG(r);
597 }
598 RETURN_LONG(0);
599 }
600
ZEND_FUNCTION(sqlrcon_getconnectionport)601 DLEXPORT ZEND_FUNCTION(sqlrcon_getconnectionport) {
602 ZVAL sqlrcon;
603 uint16_t r;
604 if (ZEND_NUM_ARGS() != 1 ||
605 GET_PARAMETERS(
606 ZEND_NUM_ARGS() TSRMLS_CC,
607 PARAMS("z")
608 &sqlrcon) == FAILURE) {
609 WRONG_PARAM_COUNT;
610 }
611 sqlrconnection *connection=NULL;
612 ZEND_FETCH_RESOURCE(connection,
613 sqlrconnection *,
614 sqlrcon,
615 -1,
616 "sqlrelay connection",
617 sqlrelay_connection);
618 if (connection) {
619 r=connection->getConnectionPort();
620 RETURN_LONG(r);
621 }
622 RETURN_LONG(0);
623 }
624
ZEND_FUNCTION(sqlrcon_getconnectionsocket)625 DLEXPORT ZEND_FUNCTION(sqlrcon_getconnectionsocket) {
626 ZVAL sqlrcon;
627 const char *r;
628 if (ZEND_NUM_ARGS() != 1 ||
629 GET_PARAMETERS(
630 ZEND_NUM_ARGS() TSRMLS_CC,
631 PARAMS("z")
632 &sqlrcon) == FAILURE) {
633 WRONG_PARAM_COUNT;
634 }
635 sqlrconnection *connection=NULL;
636 ZEND_FETCH_RESOURCE(connection,
637 sqlrconnection *,
638 sqlrcon,
639 -1,
640 "sqlrelay connection",
641 sqlrelay_connection);
642 if (connection) {
643 r=connection->getConnectionSocket();
644 if (r) {
645 RET_STRING(const_cast<char *>(r),1);
646 }
647 }
648 RETURN_FALSE;
649 }
650
ZEND_FUNCTION(sqlrcon_resumesession)651 DLEXPORT ZEND_FUNCTION(sqlrcon_resumesession) {
652 ZVAL sqlrcon;
653 ZVAL port;
654 ZVAL socket;
655 bool r;
656 if (ZEND_NUM_ARGS() != 3 ||
657 GET_PARAMETERS(
658 ZEND_NUM_ARGS() TSRMLS_CC,
659 PARAMS("zzz")
660 &sqlrcon,
661 &port,
662 &socket) == FAILURE) {
663 WRONG_PARAM_COUNT;
664 }
665 convert_to_long_ex(port);
666 convert_to_string_ex(socket);
667 sqlrconnection *connection=NULL;
668 ZEND_FETCH_RESOURCE(connection,
669 sqlrconnection *,
670 sqlrcon,
671 -1,
672 "sqlrelay connection",
673 sqlrelay_connection);
674 if (connection) {
675 r=connection->resumeSession(LVAL(port),
676 SVAL(socket));
677 RETURN_LONG(r);
678 }
679 RETURN_LONG(0);
680 }
681
ZEND_FUNCTION(sqlrcon_errormessage)682 DLEXPORT ZEND_FUNCTION(sqlrcon_errormessage) {
683 ZVAL sqlrcon;
684 const char *r;
685 if (ZEND_NUM_ARGS() != 1 ||
686 GET_PARAMETERS(
687 ZEND_NUM_ARGS() TSRMLS_CC,
688 PARAMS("z")
689 &sqlrcon) == FAILURE) {
690 WRONG_PARAM_COUNT;
691 }
692 sqlrconnection *connection=NULL;
693 ZEND_FETCH_RESOURCE(connection,
694 sqlrconnection *,
695 sqlrcon,
696 -1,
697 "sqlrelay connection",
698 sqlrelay_connection);
699 if (connection) {
700 r=connection->errorMessage();
701 if (r) {
702 RET_STRING(const_cast<char *>(r),1);
703 }
704 }
705 RETURN_NULL();
706 }
707
ZEND_FUNCTION(sqlrcon_errornumber)708 DLEXPORT ZEND_FUNCTION(sqlrcon_errornumber) {
709 ZVAL sqlrcon;
710 int64_t r;
711 if (ZEND_NUM_ARGS() != 1 ||
712 GET_PARAMETERS(
713 ZEND_NUM_ARGS() TSRMLS_CC,
714 PARAMS("z")
715 &sqlrcon) == FAILURE) {
716 WRONG_PARAM_COUNT;
717 }
718 sqlrconnection *connection=NULL;
719 ZEND_FETCH_RESOURCE(connection,
720 sqlrconnection *,
721 sqlrcon,
722 -1,
723 "sqlrelay connection",
724 sqlrelay_connection);
725 if (connection) {
726 r=connection->errorNumber();
727 if (r) {
728 RETURN_LONG(r);
729 }
730 }
731 RETURN_LONG(0);
732 }
733
ZEND_FUNCTION(sqlrcon_debugon)734 DLEXPORT ZEND_FUNCTION(sqlrcon_debugon) {
735 ZVAL sqlrcon;
736 if (ZEND_NUM_ARGS() != 1 ||
737 GET_PARAMETERS(
738 ZEND_NUM_ARGS() TSRMLS_CC,
739 PARAMS("z")
740 &sqlrcon) == FAILURE) {
741 WRONG_PARAM_COUNT;
742 }
743 sqlrconnection *connection=NULL;
744 ZEND_FETCH_RESOURCE(connection,
745 sqlrconnection *,
746 sqlrcon,
747 -1,
748 "sqlrelay connection",
749 sqlrelay_connection);
750 if (connection) {
751 connection->debugOn();
752 }
753 }
754
ZEND_FUNCTION(sqlrcon_debugoff)755 DLEXPORT ZEND_FUNCTION(sqlrcon_debugoff) {
756 ZVAL sqlrcon;
757 if (ZEND_NUM_ARGS() != 1 ||
758 GET_PARAMETERS(
759 ZEND_NUM_ARGS() TSRMLS_CC,
760 PARAMS("z")
761 &sqlrcon) == FAILURE) {
762 WRONG_PARAM_COUNT;
763 }
764 sqlrconnection *connection=NULL;
765 ZEND_FETCH_RESOURCE(connection,
766 sqlrconnection *,
767 sqlrcon,
768 -1,
769 "sqlrelay connection",
770 sqlrelay_connection);
771 if (connection) {
772 connection->debugOff();
773 }
774 }
775
ZEND_FUNCTION(sqlrcon_getdebug)776 DLEXPORT ZEND_FUNCTION(sqlrcon_getdebug) {
777 ZVAL sqlrcon;
778 bool r;
779 if (ZEND_NUM_ARGS() != 1 ||
780 GET_PARAMETERS(
781 ZEND_NUM_ARGS() TSRMLS_CC,
782 PARAMS("z")
783 &sqlrcon) == FAILURE) {
784 WRONG_PARAM_COUNT;
785 }
786 sqlrconnection *connection=NULL;
787 ZEND_FETCH_RESOURCE(connection,
788 sqlrconnection *,
789 sqlrcon,
790 -1,
791 "sqlrelay connection",
792 sqlrelay_connection);
793 if (connection) {
794 r=connection->getDebug();
795 if (r) {
796 RETURN_TRUE;
797 }
798 }
799 RETURN_FALSE;
800 }
801
ZEND_FUNCTION(sqlrcon_setdebugfile)802 DLEXPORT ZEND_FUNCTION(sqlrcon_setdebugfile) {
803 ZVAL sqlrcon;
804 ZVAL filename;
805 if (ZEND_NUM_ARGS() != 2 ||
806 GET_PARAMETERS(
807 ZEND_NUM_ARGS() TSRMLS_CC,
808 PARAMS("zz")
809 &sqlrcon,
810 &filename) == FAILURE) {
811 WRONG_PARAM_COUNT;
812 }
813 convert_to_string_ex(filename);
814 sqlrconnection *connection=NULL;
815 ZEND_FETCH_RESOURCE(connection,
816 sqlrconnection *,
817 sqlrcon,
818 -1,
819 "sqlrelay connection",
820 sqlrelay_connection);
821 if (connection) {
822 connection->setDebugFile(SVAL(filename));
823 }
824 }
825
ZEND_FUNCTION(sqlrcon_setclientinfo)826 DLEXPORT ZEND_FUNCTION(sqlrcon_setclientinfo) {
827 ZVAL sqlrcon;
828 ZVAL clientinfo;
829 if (ZEND_NUM_ARGS() != 2 ||
830 GET_PARAMETERS(
831 ZEND_NUM_ARGS() TSRMLS_CC,
832 PARAMS("zz")
833 &sqlrcon,
834 &clientinfo) == FAILURE) {
835 WRONG_PARAM_COUNT;
836 }
837 convert_to_string_ex(clientinfo);
838 sqlrconnection *connection=NULL;
839 ZEND_FETCH_RESOURCE(connection,
840 sqlrconnection *,
841 sqlrcon,
842 -1,
843 "sqlrelay connection",
844 sqlrelay_connection);
845 if (connection) {
846 connection->setClientInfo(SVAL(clientinfo));
847 }
848 }
849
ZEND_FUNCTION(sqlrcon_getclientinfo)850 DLEXPORT ZEND_FUNCTION(sqlrcon_getclientinfo) {
851 ZVAL sqlrcon;
852 const char *r;
853 if (ZEND_NUM_ARGS() != 1 ||
854 GET_PARAMETERS(
855 ZEND_NUM_ARGS() TSRMLS_CC,
856 PARAMS("z")
857 &sqlrcon) == FAILURE) {
858 WRONG_PARAM_COUNT;
859 }
860 sqlrconnection *connection=NULL;
861 ZEND_FETCH_RESOURCE(connection,
862 sqlrconnection *,
863 sqlrcon,
864 -1,
865 "sqlrelay connection",
866 sqlrelay_connection);
867 if (connection) {
868 r=connection->getClientInfo();
869 if (r) {
870 RET_STRING(const_cast<char *>(r),1);
871 }
872 }
873 RETURN_FALSE;
874 }
875
ZEND_FUNCTION(sqlrcur_alloc)876 DLEXPORT ZEND_FUNCTION(sqlrcur_alloc) {
877 zval **sqlrcon;
878 if (ZEND_NUM_ARGS() != 1 ||
879 GET_PARAMETERS(
880 ZEND_NUM_ARGS() TSRMLS_CC,
881 PARAMS("z")
882 &sqlrcon) == FAILURE) {
883 WRONG_PARAM_COUNT;
884 }
885 sqlrconnection *connection=NULL;
886 ZEND_FETCH_RESOURCE(connection,
887 sqlrconnection *,
888 sqlrcon,
889 -1,
890 "sqlrelay connection",
891 sqlrelay_connection);
892 if (!connection) {
893 RETURN_LONG(0);
894 }
895 sqlrcursor *cursor=new sqlrcursor(connection,true);
896 ZEND_REGISTER_RESOURCE(return_value,cursor,sqlrelay_cursor);
897 }
898
ZEND_FUNCTION(sqlrcur_free)899 DLEXPORT ZEND_FUNCTION(sqlrcur_free) {
900 ZVAL sqlrcur;
901 if (ZEND_NUM_ARGS() != 1 ||
902 GET_PARAMETERS(
903 ZEND_NUM_ARGS() TSRMLS_CC,
904 PARAMS("z")
905 &sqlrcur) == FAILURE) {
906 WRONG_PARAM_COUNT;
907 }
908 sqlrcursor *cursor=NULL;
909 ZEND_FETCH_RESOURCE(cursor,
910 sqlrcursor *,
911 sqlrcur,
912 -1,
913 "sqlrelay cursor",
914 sqlrelay_cursor);
915 ZEND_LIST_DELETE(sqlrcur);
916 }
917
ZEND_FUNCTION(sqlrcur_setresultsetbuffersize)918 DLEXPORT ZEND_FUNCTION(sqlrcur_setresultsetbuffersize) {
919 ZVAL sqlrcur;
920 ZVAL rows;
921 if (ZEND_NUM_ARGS() != 2 ||
922 GET_PARAMETERS(
923 ZEND_NUM_ARGS() TSRMLS_CC,
924 PARAMS("zz")
925 &sqlrcur,&rows) == FAILURE) {
926 WRONG_PARAM_COUNT;
927 }
928 convert_to_long_ex(rows);
929 sqlrcursor *cursor=NULL;
930 ZEND_FETCH_RESOURCE(cursor,
931 sqlrcursor *,
932 sqlrcur,
933 -1,
934 "sqlrelay cursor",
935 sqlrelay_cursor);
936 if (cursor) {
937 cursor->setResultSetBufferSize(LVAL(rows));
938 }
939 }
940
ZEND_FUNCTION(sqlrcur_getresultsetbuffersize)941 DLEXPORT ZEND_FUNCTION(sqlrcur_getresultsetbuffersize) {
942 ZVAL sqlrcur;
943 uint64_t r;
944 if (ZEND_NUM_ARGS() != 1 ||
945 GET_PARAMETERS(
946 ZEND_NUM_ARGS() TSRMLS_CC,
947 PARAMS("z")
948 &sqlrcur) == FAILURE) {
949 WRONG_PARAM_COUNT;
950 }
951 sqlrcursor *cursor=NULL;
952 ZEND_FETCH_RESOURCE(cursor,
953 sqlrcursor *,
954 sqlrcur,
955 -1,
956 "sqlrelay cursor",
957 sqlrelay_cursor);
958 if (cursor) {
959 r=cursor->getResultSetBufferSize();
960 RETURN_LONG(r);
961 }
962 RETURN_LONG(0);
963 }
964
ZEND_FUNCTION(sqlrcur_dontgetcolumninfo)965 DLEXPORT ZEND_FUNCTION(sqlrcur_dontgetcolumninfo) {
966 ZVAL sqlrcur;
967 if (ZEND_NUM_ARGS() != 1 ||
968 GET_PARAMETERS(
969 ZEND_NUM_ARGS() TSRMLS_CC,
970 PARAMS("z")
971 &sqlrcur) == FAILURE) {
972 WRONG_PARAM_COUNT;
973 }
974 sqlrcursor *cursor=NULL;
975 ZEND_FETCH_RESOURCE(cursor,
976 sqlrcursor *,
977 sqlrcur,
978 -1,
979 "sqlrelay cursor",
980 sqlrelay_cursor);
981 if (cursor) {
982 cursor->dontGetColumnInfo();
983 }
984 }
985
ZEND_FUNCTION(sqlrcur_getcolumninfo)986 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumninfo) {
987 ZVAL sqlrcur;
988 if (ZEND_NUM_ARGS() != 1 ||
989 GET_PARAMETERS(
990 ZEND_NUM_ARGS() TSRMLS_CC,
991 PARAMS("z")
992 &sqlrcur) == FAILURE) {
993 WRONG_PARAM_COUNT;
994 }
995 sqlrcursor *cursor=NULL;
996 ZEND_FETCH_RESOURCE(cursor,
997 sqlrcursor *,
998 sqlrcur,
999 -1,
1000 "sqlrelay cursor",
1001 sqlrelay_cursor);
1002 if (cursor) {
1003 cursor->getColumnInfo();
1004 }
1005 }
1006
ZEND_FUNCTION(sqlrcur_mixedcasecolumnnames)1007 DLEXPORT ZEND_FUNCTION(sqlrcur_mixedcasecolumnnames) {
1008 ZVAL sqlrcur;
1009 if (ZEND_NUM_ARGS() != 1 ||
1010 GET_PARAMETERS(
1011 ZEND_NUM_ARGS() TSRMLS_CC,
1012 PARAMS("z")
1013 &sqlrcur) == FAILURE) {
1014 WRONG_PARAM_COUNT;
1015 }
1016 sqlrcursor *cursor=NULL;
1017 ZEND_FETCH_RESOURCE(cursor,
1018 sqlrcursor *,
1019 sqlrcur,
1020 -1,
1021 "sqlrelay cursor",
1022 sqlrelay_cursor);
1023 if (cursor) {
1024 cursor->mixedCaseColumnNames();
1025 }
1026 }
1027
ZEND_FUNCTION(sqlrcur_uppercasecolumnnames)1028 DLEXPORT ZEND_FUNCTION(sqlrcur_uppercasecolumnnames) {
1029 ZVAL sqlrcur;
1030 if (ZEND_NUM_ARGS() != 1 ||
1031 GET_PARAMETERS(
1032 ZEND_NUM_ARGS() TSRMLS_CC,
1033 PARAMS("z")
1034 &sqlrcur) == FAILURE) {
1035 WRONG_PARAM_COUNT;
1036 }
1037 sqlrcursor *cursor=NULL;
1038 ZEND_FETCH_RESOURCE(cursor,
1039 sqlrcursor *,
1040 sqlrcur,
1041 -1,
1042 "sqlrelay cursor",
1043 sqlrelay_cursor);
1044 if (cursor) {
1045 cursor->upperCaseColumnNames();
1046 }
1047 }
1048
ZEND_FUNCTION(sqlrcur_lowercasecolumnnames)1049 DLEXPORT ZEND_FUNCTION(sqlrcur_lowercasecolumnnames) {
1050 ZVAL sqlrcur;
1051 if (ZEND_NUM_ARGS() != 1 ||
1052 GET_PARAMETERS(
1053 ZEND_NUM_ARGS() TSRMLS_CC,
1054 PARAMS("z")
1055 &sqlrcur) == FAILURE) {
1056 WRONG_PARAM_COUNT;
1057 }
1058 sqlrcursor *cursor=NULL;
1059 ZEND_FETCH_RESOURCE(cursor,
1060 sqlrcursor *,
1061 sqlrcur,
1062 -1,
1063 "sqlrelay cursor",
1064 sqlrelay_cursor);
1065 if (cursor) {
1066 cursor->lowerCaseColumnNames();
1067 }
1068 }
1069
ZEND_FUNCTION(sqlrcur_cachetofile)1070 DLEXPORT ZEND_FUNCTION(sqlrcur_cachetofile) {
1071 ZVAL sqlrcur;
1072 ZVAL filename;
1073 if (ZEND_NUM_ARGS() != 2 ||
1074 GET_PARAMETERS(
1075 ZEND_NUM_ARGS() TSRMLS_CC,
1076 PARAMS("zz")
1077 &sqlrcur,
1078 &filename) == FAILURE) {
1079 WRONG_PARAM_COUNT;
1080 }
1081 convert_to_string_ex(filename);
1082 sqlrcursor *cursor=NULL;
1083 ZEND_FETCH_RESOURCE(cursor,
1084 sqlrcursor *,
1085 sqlrcur,
1086 -1,
1087 "sqlrelay cursor",
1088 sqlrelay_cursor);
1089 if (cursor) {
1090 cursor->cacheToFile(SVAL(filename));
1091 }
1092 }
1093
ZEND_FUNCTION(sqlrcur_setcachettl)1094 DLEXPORT ZEND_FUNCTION(sqlrcur_setcachettl) {
1095 ZVAL sqlrcur;
1096 ZVAL ttl;
1097 if (ZEND_NUM_ARGS() != 2 ||
1098 GET_PARAMETERS(
1099 ZEND_NUM_ARGS() TSRMLS_CC,
1100 PARAMS("zz")
1101 &sqlrcur,
1102 &ttl) == FAILURE) {
1103 WRONG_PARAM_COUNT;
1104 }
1105 convert_to_long_ex(ttl);
1106 sqlrcursor *cursor=NULL;
1107 ZEND_FETCH_RESOURCE(cursor,
1108 sqlrcursor *,
1109 sqlrcur,
1110 -1,
1111 "sqlrelay cursor",
1112 sqlrelay_cursor);
1113 if (cursor) {
1114 cursor->setCacheTtl(LVAL(ttl));
1115 }
1116 }
1117
ZEND_FUNCTION(sqlrcur_getcachefilename)1118 DLEXPORT ZEND_FUNCTION(sqlrcur_getcachefilename) {
1119 ZVAL sqlrcur;
1120 const char *r;
1121 if (ZEND_NUM_ARGS() != 1 ||
1122 GET_PARAMETERS(
1123 ZEND_NUM_ARGS() TSRMLS_CC,
1124 PARAMS("z")
1125 &sqlrcur) == FAILURE) {
1126 WRONG_PARAM_COUNT;
1127 }
1128 sqlrcursor *cursor=NULL;
1129 ZEND_FETCH_RESOURCE(cursor,
1130 sqlrcursor *,
1131 sqlrcur,
1132 -1,
1133 "sqlrelay cursor",
1134 sqlrelay_cursor);
1135 if (cursor) {
1136 r=cursor->getCacheFileName();
1137 if (r) {
1138 RET_STRING(const_cast<char *>(r),1);
1139 }
1140 }
1141 RETURN_FALSE;
1142 }
1143
ZEND_FUNCTION(sqlrcur_cacheoff)1144 DLEXPORT ZEND_FUNCTION(sqlrcur_cacheoff) {
1145 ZVAL sqlrcur;
1146 if (ZEND_NUM_ARGS() != 1 ||
1147 GET_PARAMETERS(
1148 ZEND_NUM_ARGS() TSRMLS_CC,
1149 PARAMS("z")
1150 &sqlrcur) == FAILURE) {
1151 WRONG_PARAM_COUNT;
1152 }
1153 sqlrcursor *cursor=NULL;
1154 ZEND_FETCH_RESOURCE(cursor,
1155 sqlrcursor *,
1156 sqlrcur,
1157 -1,
1158 "sqlrelay cursor",
1159 sqlrelay_cursor);
1160 if (cursor) {
1161 cursor->cacheOff();
1162 }
1163 }
1164
ZEND_FUNCTION(sqlrcur_getdatabaselist)1165 DLEXPORT ZEND_FUNCTION(sqlrcur_getdatabaselist) {
1166 ZVAL sqlrcur;
1167 ZVAL wild;
1168 bool r;
1169 if (ZEND_NUM_ARGS() != 2 ||
1170 GET_PARAMETERS(
1171 ZEND_NUM_ARGS() TSRMLS_CC,
1172 PARAMS("zz")
1173 &sqlrcur,
1174 &wild) == FAILURE) {
1175 WRONG_PARAM_COUNT;
1176 }
1177 convert_to_string_ex(wild);
1178 sqlrcursor *cursor=NULL;
1179 ZEND_FETCH_RESOURCE(cursor,
1180 sqlrcursor *,
1181 sqlrcur,
1182 -1,
1183 "sqlrelay cursor",
1184 sqlrelay_cursor);
1185 if (cursor) {
1186 r=cursor->getDatabaseList(SVAL(wild));
1187 RETURN_LONG(r);
1188 }
1189 RETURN_LONG(0);
1190 }
1191
ZEND_FUNCTION(sqlrcur_gettablelist)1192 DLEXPORT ZEND_FUNCTION(sqlrcur_gettablelist) {
1193 ZVAL sqlrcur;
1194 ZVAL wild;
1195 bool r;
1196 if (ZEND_NUM_ARGS() != 2 ||
1197 GET_PARAMETERS(
1198 ZEND_NUM_ARGS() TSRMLS_CC,
1199 PARAMS("zz")
1200 &sqlrcur,
1201 &wild) == FAILURE) {
1202 WRONG_PARAM_COUNT;
1203 }
1204 convert_to_string_ex(wild);
1205 sqlrcursor *cursor=NULL;
1206 ZEND_FETCH_RESOURCE(cursor,
1207 sqlrcursor *,
1208 sqlrcur,
1209 -1,
1210 "sqlrelay cursor",
1211 sqlrelay_cursor);
1212 if (cursor) {
1213 r=cursor->getTableList(SVAL(wild));
1214 RETURN_LONG(r);
1215 }
1216 RETURN_LONG(0);
1217 }
1218
ZEND_FUNCTION(sqlrcur_getcolumnlist)1219 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnlist) {
1220 ZVAL sqlrcur;
1221 ZVAL table;
1222 ZVAL wild;
1223 bool r;
1224 if (ZEND_NUM_ARGS() != 3 ||
1225 GET_PARAMETERS(
1226 ZEND_NUM_ARGS() TSRMLS_CC,
1227 PARAMS("zzz")
1228 &sqlrcur,
1229 &table,
1230 &wild) == FAILURE) {
1231 WRONG_PARAM_COUNT;
1232 }
1233 convert_to_string_ex(table);
1234 convert_to_string_ex(wild);
1235 sqlrcursor *cursor=NULL;
1236 ZEND_FETCH_RESOURCE(cursor,
1237 sqlrcursor *,
1238 sqlrcur,
1239 -1,
1240 "sqlrelay cursor",
1241 sqlrelay_cursor);
1242 if (cursor) {
1243 r=cursor->getColumnList(SVAL(table),
1244 SVAL(wild));
1245 RETURN_LONG(r);
1246 }
1247 RETURN_LONG(0);
1248 }
1249
ZEND_FUNCTION(sqlrcur_sendquery)1250 DLEXPORT ZEND_FUNCTION(sqlrcur_sendquery) {
1251 ZVAL sqlrcur;
1252 ZVAL query;
1253 bool r;
1254 if (ZEND_NUM_ARGS() != 2 ||
1255 GET_PARAMETERS(
1256 ZEND_NUM_ARGS() TSRMLS_CC,
1257 PARAMS("zz")
1258 &sqlrcur,
1259 &query) == FAILURE) {
1260 WRONG_PARAM_COUNT;
1261 }
1262 convert_to_string_ex(query);
1263 sqlrcursor *cursor=NULL;
1264 ZEND_FETCH_RESOURCE(cursor,
1265 sqlrcursor *,
1266 sqlrcur,
1267 -1,
1268 "sqlrelay cursor",
1269 sqlrelay_cursor);
1270 if (cursor) {
1271 r=cursor->sendQuery(SVAL(query));
1272 RETURN_LONG(r);
1273 }
1274 RETURN_LONG(0);
1275 }
1276
ZEND_FUNCTION(sqlrcur_sendquerywithlength)1277 DLEXPORT ZEND_FUNCTION(sqlrcur_sendquerywithlength) {
1278 ZVAL sqlrcur;
1279 ZVAL query;
1280 ZVAL length;
1281 bool r;
1282 if (ZEND_NUM_ARGS() != 3 ||
1283 GET_PARAMETERS(
1284 ZEND_NUM_ARGS() TSRMLS_CC,
1285 PARAMS("zzz")
1286 &sqlrcur,
1287 &query,
1288 &length) == FAILURE) {
1289 WRONG_PARAM_COUNT;
1290 }
1291 convert_to_string_ex(query);
1292 convert_to_long_ex(length);
1293 sqlrcursor *cursor=NULL;
1294 ZEND_FETCH_RESOURCE(cursor,
1295 sqlrcursor *,
1296 sqlrcur,
1297 -1,
1298 "sqlrelay cursor",
1299 sqlrelay_cursor);
1300 if (cursor) {
1301 r=cursor->sendQuery(SVAL(query),
1302 LVAL(length));
1303 RETURN_LONG(r);
1304 }
1305 RETURN_LONG(0);
1306 }
1307
ZEND_FUNCTION(sqlrcur_sendfilequery)1308 DLEXPORT ZEND_FUNCTION(sqlrcur_sendfilequery) {
1309 ZVAL sqlrcur;
1310 ZVAL path;
1311 ZVAL filename;
1312 bool r;
1313 if (ZEND_NUM_ARGS() != 3 ||
1314 GET_PARAMETERS(
1315 ZEND_NUM_ARGS() TSRMLS_CC,
1316 PARAMS("zzz")
1317 &sqlrcur,
1318 &path,
1319 &filename) == FAILURE) {
1320 WRONG_PARAM_COUNT;
1321 }
1322 convert_to_string_ex(path);
1323 convert_to_string_ex(filename);
1324 sqlrcursor *cursor=NULL;
1325 ZEND_FETCH_RESOURCE(cursor,
1326 sqlrcursor *,
1327 sqlrcur,
1328 -1,
1329 "sqlrelay cursor",
1330 sqlrelay_cursor);
1331 if (cursor) {
1332 r=((sqlrcursor *)LVAL(sqlrcur))->
1333 sendFileQuery(SVAL(path),
1334 SVAL(filename));
1335 RETURN_LONG(r);
1336 }
1337 RETURN_LONG(0);
1338 }
1339
ZEND_FUNCTION(sqlrcur_preparequery)1340 DLEXPORT ZEND_FUNCTION(sqlrcur_preparequery) {
1341 ZVAL sqlrcur;
1342 ZVAL query;
1343 if (ZEND_NUM_ARGS() != 2 ||
1344 GET_PARAMETERS(
1345 ZEND_NUM_ARGS() TSRMLS_CC,
1346 PARAMS("zz")
1347 &sqlrcur,
1348 &query) == FAILURE) {
1349 WRONG_PARAM_COUNT;
1350 }
1351 convert_to_string_ex(query);
1352 sqlrcursor *cursor=NULL;
1353 ZEND_FETCH_RESOURCE(cursor,
1354 sqlrcursor *,
1355 sqlrcur,
1356 -1,
1357 "sqlrelay cursor",
1358 sqlrelay_cursor);
1359 if (cursor) {
1360 cursor->prepareQuery(SVAL(query));
1361 }
1362 }
1363
ZEND_FUNCTION(sqlrcur_preparequerywithlength)1364 DLEXPORT ZEND_FUNCTION(sqlrcur_preparequerywithlength) {
1365 ZVAL sqlrcur;
1366 ZVAL query;
1367 ZVAL length;
1368 if (ZEND_NUM_ARGS() != 3 ||
1369 GET_PARAMETERS(
1370 ZEND_NUM_ARGS() TSRMLS_CC,
1371 PARAMS("zzz")
1372 &sqlrcur,
1373 &query,
1374 &length) == FAILURE) {
1375 WRONG_PARAM_COUNT;
1376 }
1377 convert_to_string_ex(query);
1378 convert_to_long_ex(length);
1379 sqlrcursor *cursor=NULL;
1380 ZEND_FETCH_RESOURCE(cursor,
1381 sqlrcursor *,
1382 sqlrcur,
1383 -1,
1384 "sqlrelay cursor",
1385 sqlrelay_cursor);
1386 if (cursor) {
1387 cursor->prepareQuery(SVAL(query),
1388 LVAL(length));
1389 }
1390 }
1391
ZEND_FUNCTION(sqlrcur_preparefilequery)1392 DLEXPORT ZEND_FUNCTION(sqlrcur_preparefilequery) {
1393 ZVAL sqlrcur;
1394 ZVAL path;
1395 ZVAL filename;
1396 bool r;
1397 if (ZEND_NUM_ARGS() != 3 ||
1398 GET_PARAMETERS(
1399 ZEND_NUM_ARGS() TSRMLS_CC,
1400 PARAMS("zzz")
1401 &sqlrcur,
1402 &path,
1403 &filename) == FAILURE) {
1404 WRONG_PARAM_COUNT;
1405 }
1406 convert_to_string_ex(path);
1407 convert_to_string_ex(filename);
1408 sqlrcursor *cursor=NULL;
1409 ZEND_FETCH_RESOURCE(cursor,
1410 sqlrcursor *,
1411 sqlrcur,
1412 -1,
1413 "sqlrelay cursor",
1414 sqlrelay_cursor);
1415 if (cursor) {
1416 r=cursor->prepareFileQuery(SVAL(path),
1417 SVAL(filename));
1418 RETURN_LONG(r);
1419 }
1420 RETURN_LONG(0);
1421 }
1422
ZEND_FUNCTION(sqlrcur_substitution)1423 DLEXPORT ZEND_FUNCTION(sqlrcur_substitution) {
1424 ZVAL sqlrcur;
1425 ZVAL variable;
1426 ZVAL value;
1427 ZVAL precision;
1428 ZVAL scale;
1429 if (ZEND_NUM_ARGS() != 3 ||
1430 GET_PARAMETERS(
1431 ZEND_NUM_ARGS() TSRMLS_CC,
1432 PARAMS("zzz")
1433 &sqlrcur,
1434 &variable,
1435 &value) == FAILURE) {
1436 if (ZEND_NUM_ARGS() != 5 ||
1437 GET_PARAMETERS(
1438 ZEND_NUM_ARGS() TSRMLS_CC,
1439 PARAMS("zzzzz")
1440 &sqlrcur,
1441 &variable,
1442 &value,
1443 &precision,
1444 &scale)== FAILURE) {
1445 WRONG_PARAM_COUNT;
1446 }
1447 }
1448 convert_to_string_ex(variable);
1449 sqlrcursor *cursor=NULL;
1450 ZEND_FETCH_RESOURCE(cursor,
1451 sqlrcursor *,
1452 sqlrcur,
1453 -1,
1454 "sqlrelay cursor",
1455 sqlrelay_cursor);
1456 if (cursor) {
1457 if (TYPE(value)==IS_STRING) {
1458 convert_to_string_ex(value);
1459 cursor->substitution(SVAL(variable),
1460 SVAL(value));
1461 RETURN_LONG(1);
1462 } else if (TYPE(value)==IS_LONG) {
1463 convert_to_long_ex(value);
1464 cursor->substitution(SVAL(variable),
1465 LVAL(value));
1466 RETURN_LONG(1);
1467 } else if (ZEND_NUM_ARGS()==5 && TYPE(value)==IS_DOUBLE) {
1468 convert_to_double_ex(value);
1469 cursor->substitution(
1470 SVAL(variable),
1471 DVAL(value),
1472 (unsigned short)LVAL(precision),
1473 (unsigned short)LVAL(scale));
1474 RETURN_LONG(1);
1475 } else if (TYPE(value)==IS_NULL) {
1476 cursor->substitution(
1477 SVAL(variable),
1478 (const char *)NULL);
1479 RETURN_LONG(1);
1480 }
1481 }
1482 RETURN_LONG(0);
1483 }
1484
ZEND_FUNCTION(sqlrcur_clearbinds)1485 DLEXPORT ZEND_FUNCTION(sqlrcur_clearbinds) {
1486 ZVAL sqlrcur;
1487 if (ZEND_NUM_ARGS() != 1 ||
1488 GET_PARAMETERS(
1489 ZEND_NUM_ARGS() TSRMLS_CC,
1490 PARAMS("z")
1491 &sqlrcur) == FAILURE) {
1492 WRONG_PARAM_COUNT;
1493 }
1494 sqlrcursor *cursor=NULL;
1495 ZEND_FETCH_RESOURCE(cursor,
1496 sqlrcursor *,
1497 sqlrcur,
1498 -1,
1499 "sqlrelay cursor",
1500 sqlrelay_cursor);
1501 if (cursor) {
1502 cursor->clearBinds();
1503 }
1504 }
1505
ZEND_FUNCTION(sqlrcur_countbindvariables)1506 DLEXPORT ZEND_FUNCTION(sqlrcur_countbindvariables) {
1507 ZVAL sqlrcur;
1508 uint16_t r;
1509 if (ZEND_NUM_ARGS() != 1 ||
1510 GET_PARAMETERS(
1511 ZEND_NUM_ARGS() TSRMLS_CC,
1512 PARAMS("z")
1513 &sqlrcur) == FAILURE) {
1514 WRONG_PARAM_COUNT;
1515 }
1516 sqlrcursor *cursor=NULL;
1517 ZEND_FETCH_RESOURCE(cursor,
1518 sqlrcursor *,
1519 sqlrcur,
1520 -1,
1521 "sqlrelay cursor",
1522 sqlrelay_cursor);
1523 if (cursor) {
1524 r=cursor->countBindVariables();
1525 RETURN_LONG(r);
1526 }
1527 RETURN_LONG(0);
1528 }
1529
ZEND_FUNCTION(sqlrcur_inputbind)1530 DLEXPORT ZEND_FUNCTION(sqlrcur_inputbind) {
1531 ZVAL sqlrcur;
1532 ZVAL variable;
1533 ZVAL value;
1534 ZVAL precision;
1535 ZVAL scale;
1536 ZVAL length;
1537 if (ZEND_NUM_ARGS() != 3 ||
1538 GET_PARAMETERS(
1539 ZEND_NUM_ARGS() TSRMLS_CC,
1540 PARAMS("zzz")
1541 &sqlrcur,
1542 &variable,
1543 &value) == FAILURE) {
1544 if (ZEND_NUM_ARGS() != 4 ||
1545 GET_PARAMETERS(
1546 ZEND_NUM_ARGS() TSRMLS_CC,
1547 PARAMS("zzzz")
1548 &sqlrcur,
1549 &variable,
1550 &value,
1551 &length)== FAILURE) {
1552 if (ZEND_NUM_ARGS() != 5 ||
1553 GET_PARAMETERS(
1554 ZEND_NUM_ARGS() TSRMLS_CC,
1555 PARAMS("zzzzz")
1556 &sqlrcur,
1557 &variable,
1558 &value,
1559 &precision,
1560 &scale)== FAILURE) {
1561 WRONG_PARAM_COUNT;
1562 }
1563 }
1564 }
1565 convert_to_string_ex(variable);
1566 sqlrcursor *cursor=NULL;
1567 ZEND_FETCH_RESOURCE(cursor,
1568 sqlrcursor *,
1569 sqlrcur,
1570 -1,
1571 "sqlrelay cursor",
1572 sqlrelay_cursor);
1573 if (cursor) {
1574 if (TYPE(value)==IS_STRING) {
1575 convert_to_string_ex(value);
1576 if (ZEND_NUM_ARGS() == 4 && LVAL(length)>0) {
1577 cursor->inputBind(
1578 SVAL(variable),
1579 SVAL(value),
1580 LVAL(length));
1581 } else {
1582 cursor->inputBind(
1583 SVAL(variable),
1584 SVAL(value));
1585 }
1586 RETURN_LONG(1);
1587 } else if (TYPE(value)==IS_LONG) {
1588 convert_to_long_ex(value);
1589 cursor->inputBind(SVAL(variable),
1590 LVAL(value));
1591 RETURN_LONG(1);
1592 } else if (ZEND_NUM_ARGS()==5 && TYPE(value)==IS_DOUBLE) {
1593 convert_to_double_ex(value);
1594 cursor->inputBind(
1595 SVAL(variable),
1596 DVAL(value),
1597 (unsigned short)LVAL(precision),
1598 (unsigned short)LVAL(scale));
1599 RETURN_LONG(1);
1600 } else if (TYPE(value)==IS_NULL) {
1601 cursor->inputBind(
1602 SVAL(variable),
1603 (const char *)NULL);
1604 RETURN_LONG(1);
1605 }
1606 }
1607 RETURN_LONG(0);
1608 }
1609
ZEND_FUNCTION(sqlrcur_inputbindblob)1610 DLEXPORT ZEND_FUNCTION(sqlrcur_inputbindblob) {
1611 ZVAL sqlrcur;
1612 ZVAL variable;
1613 ZVAL value;
1614 ZVAL size;
1615 if (ZEND_NUM_ARGS() != 4 ||
1616 GET_PARAMETERS(
1617 ZEND_NUM_ARGS() TSRMLS_CC,
1618 PARAMS("zzzz")
1619 &sqlrcur,
1620 &variable,
1621 &value,
1622 &size) == FAILURE) {
1623 WRONG_PARAM_COUNT;
1624 }
1625 convert_to_string_ex(variable);
1626 convert_to_string_ex(value);
1627 convert_to_long_ex(size);
1628 sqlrcursor *cursor=NULL;
1629 ZEND_FETCH_RESOURCE(cursor,
1630 sqlrcursor *,
1631 sqlrcur,
1632 -1,
1633 "sqlrelay cursor",
1634 sqlrelay_cursor);
1635 if (cursor) {
1636 cursor->inputBindBlob(SVAL(variable),
1637 SVAL(value),
1638 LVAL(size));
1639 RETURN_LONG(1);
1640 }
1641 RETURN_LONG(0);
1642 }
1643
ZEND_FUNCTION(sqlrcur_inputbindclob)1644 DLEXPORT ZEND_FUNCTION(sqlrcur_inputbindclob) {
1645 ZVAL sqlrcur;
1646 ZVAL variable;
1647 ZVAL value;
1648 ZVAL size;
1649 if (ZEND_NUM_ARGS() != 4 ||
1650 GET_PARAMETERS(
1651 ZEND_NUM_ARGS() TSRMLS_CC,
1652 PARAMS("zzzz")
1653 &sqlrcur,
1654 &variable,
1655 &value,
1656 &size) == FAILURE) {
1657 WRONG_PARAM_COUNT;
1658 }
1659 convert_to_string_ex(variable);
1660 convert_to_string_ex(value);
1661 convert_to_long_ex(size);
1662 sqlrcursor *cursor=NULL;
1663 ZEND_FETCH_RESOURCE(cursor,
1664 sqlrcursor *,
1665 sqlrcur,
1666 -1,
1667 "sqlrelay cursor",
1668 sqlrelay_cursor);
1669 if (cursor) {
1670 cursor->inputBindClob(SVAL(variable),
1671 SVAL(value),
1672 LVAL(size));
1673 RETURN_LONG(1);
1674 }
1675 RETURN_LONG(0);
1676 }
1677
ZEND_FUNCTION(sqlrcur_defineoutputbindstring)1678 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindstring) {
1679 ZVAL sqlrcur;
1680 ZVAL variable;
1681 ZVAL length;
1682 if (ZEND_NUM_ARGS() != 3 ||
1683 GET_PARAMETERS(
1684 ZEND_NUM_ARGS() TSRMLS_CC,
1685 PARAMS("zzz")
1686 &sqlrcur,
1687 &variable,
1688 &length) == FAILURE) {
1689 WRONG_PARAM_COUNT;
1690 }
1691 convert_to_string_ex(variable);
1692 convert_to_long_ex(length);
1693 sqlrcursor *cursor=NULL;
1694 ZEND_FETCH_RESOURCE(cursor,
1695 sqlrcursor *,
1696 sqlrcur,
1697 -1,
1698 "sqlrelay cursor",
1699 sqlrelay_cursor);
1700 if (cursor) {
1701 cursor->defineOutputBindString(
1702 SVAL(variable),
1703 LVAL(length));
1704 }
1705 }
1706
ZEND_FUNCTION(sqlrcur_defineoutputbindinteger)1707 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindinteger) {
1708 ZVAL sqlrcur;
1709 ZVAL variable;
1710 if (ZEND_NUM_ARGS() != 2 ||
1711 GET_PARAMETERS(
1712 ZEND_NUM_ARGS() TSRMLS_CC,
1713 PARAMS("zz")
1714 &sqlrcur,
1715 &variable) == FAILURE) {
1716 WRONG_PARAM_COUNT;
1717 }
1718 convert_to_string_ex(variable);
1719 sqlrcursor *cursor=NULL;
1720 ZEND_FETCH_RESOURCE(cursor,
1721 sqlrcursor *,
1722 sqlrcur,
1723 -1,
1724 "sqlrelay cursor",
1725 sqlrelay_cursor);
1726 if (cursor) {
1727 cursor->defineOutputBindInteger(SVAL(variable));
1728 }
1729 }
1730
ZEND_FUNCTION(sqlrcur_defineoutputbinddouble)1731 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbinddouble) {
1732 ZVAL sqlrcur;
1733 ZVAL variable;
1734 if (ZEND_NUM_ARGS() != 2 ||
1735 GET_PARAMETERS(
1736 ZEND_NUM_ARGS() TSRMLS_CC,
1737 PARAMS("zz")
1738 &sqlrcur,
1739 &variable) == FAILURE) {
1740 WRONG_PARAM_COUNT;
1741 }
1742 convert_to_string_ex(variable);
1743 sqlrcursor *cursor=NULL;
1744 ZEND_FETCH_RESOURCE(cursor,
1745 sqlrcursor *,
1746 sqlrcur,
1747 -1,
1748 "sqlrelay cursor",
1749 sqlrelay_cursor);
1750 if (cursor) {
1751 cursor->defineOutputBindDouble(SVAL(variable));
1752 }
1753 }
1754
ZEND_FUNCTION(sqlrcur_defineoutputbindblob)1755 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindblob) {
1756 ZVAL sqlrcur;
1757 ZVAL variable;
1758 if (ZEND_NUM_ARGS() != 2 ||
1759 GET_PARAMETERS(
1760 ZEND_NUM_ARGS() TSRMLS_CC,
1761 PARAMS("zz")
1762 &sqlrcur,
1763 &variable) == FAILURE) {
1764 WRONG_PARAM_COUNT;
1765 }
1766 convert_to_string_ex(variable);
1767 sqlrcursor *cursor=NULL;
1768 ZEND_FETCH_RESOURCE(cursor,
1769 sqlrcursor *,
1770 sqlrcur,
1771 -1,
1772 "sqlrelay cursor",
1773 sqlrelay_cursor);
1774 if (cursor) {
1775 cursor->defineOutputBindBlob(SVAL(variable));
1776 }
1777 }
1778
ZEND_FUNCTION(sqlrcur_defineoutputbindclob)1779 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindclob) {
1780 ZVAL sqlrcur;
1781 ZVAL variable;
1782 if (ZEND_NUM_ARGS() != 2 ||
1783 GET_PARAMETERS(
1784 ZEND_NUM_ARGS() TSRMLS_CC,
1785 PARAMS("zz")
1786 &sqlrcur,
1787 &variable) == FAILURE) {
1788 WRONG_PARAM_COUNT;
1789 }
1790 convert_to_string_ex(variable);
1791 sqlrcursor *cursor=NULL;
1792 ZEND_FETCH_RESOURCE(cursor,
1793 sqlrcursor *,
1794 sqlrcur,
1795 -1,
1796 "sqlrelay cursor",
1797 sqlrelay_cursor);
1798 if (cursor) {
1799 cursor->defineOutputBindClob(SVAL(variable));
1800 }
1801 }
1802
ZEND_FUNCTION(sqlrcur_defineoutputbindcursor)1803 DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindcursor) {
1804 ZVAL sqlrcur;
1805 ZVAL variable;
1806 if (ZEND_NUM_ARGS() != 2 ||
1807 GET_PARAMETERS(
1808 ZEND_NUM_ARGS() TSRMLS_CC,
1809 PARAMS("zz")
1810 &sqlrcur,
1811 &variable) == FAILURE) {
1812 WRONG_PARAM_COUNT;
1813 }
1814 convert_to_string_ex(variable);
1815 sqlrcursor *cursor=NULL;
1816 ZEND_FETCH_RESOURCE(cursor,
1817 sqlrcursor *,
1818 sqlrcur,
1819 -1,
1820 "sqlrelay cursor",
1821 sqlrelay_cursor);
1822 if (cursor) {
1823 cursor->defineOutputBindCursor(SVAL(variable));
1824 }
1825 }
1826
ZEND_FUNCTION(sqlrcur_substitutions)1827 DLEXPORT ZEND_FUNCTION(sqlrcur_substitutions) {
1828 ZVAL sqlrcur;
1829 ZVAL variables;
1830 ZVAL values;
1831 ZVAL precisions;
1832 ZVAL scales;
1833 ZVAL var;
1834 ZVAL val;
1835 ZVAL precision;
1836 ZVAL scale;
1837 unsigned int i;
1838 if (ZEND_NUM_ARGS() != 3 ||
1839 GET_PARAMETERS(
1840 ZEND_NUM_ARGS() TSRMLS_CC,
1841 PARAMS("zzz")
1842 &sqlrcur,
1843 &variables,
1844 &values) == FAILURE) {
1845 if (ZEND_NUM_ARGS() != 5 ||
1846 GET_PARAMETERS(
1847 ZEND_NUM_ARGS() TSRMLS_CC,
1848 PARAMS("zzzzz")
1849 &sqlrcur,
1850 &variables,
1851 &values,
1852 &precisions,
1853 &scales)== FAILURE) {
1854 WRONG_PARAM_COUNT;
1855 } else {
1856 convert_to_array_ex(precisions);
1857 convert_to_array_ex(scales);
1858 }
1859 }
1860 convert_to_array_ex(variables);
1861 convert_to_array_ex(values);
1862 sqlrcursor *cursor=NULL;
1863 ZEND_FETCH_RESOURCE(cursor,
1864 sqlrcursor *,
1865 sqlrcur,
1866 -1,
1867 "sqlrelay cursor",
1868 sqlrelay_cursor);
1869 long success=1;
1870 if (cursor) {
1871 for (i=0; i<ARRVAL(variables)->nNumOfElements; i++) {
1872 HASH_INDEX_FIND(ARRVAL(variables),i,var);
1873 HASH_INDEX_FIND(ARRVAL(values),i,val);
1874 if (TYPE(val)==IS_STRING) {
1875 convert_to_string_ex(val);
1876 cursor->substitution(SVAL(var),
1877 SVAL(val));
1878 } else if (TYPE(val)==IS_LONG) {
1879 convert_to_long_ex(val);
1880 cursor->substitution(SVAL(var),
1881 LVAL(val));
1882 } else if (ZEND_NUM_ARGS()==5 &&
1883 TYPE(val)==IS_DOUBLE) {
1884 HASH_INDEX_FIND(ARRVAL(precisions),i,precision);
1885 HASH_INDEX_FIND(ARRVAL(scales),i,scale);
1886 convert_to_double_ex(val);
1887 convert_to_long_ex(precision);
1888 convert_to_long_ex(scale);
1889 cursor->substitution(
1890 SVAL(var),
1891 DVAL(val),
1892 (unsigned short)LVAL(precision),
1893 (unsigned short)LVAL(scale));
1894 } else if (TYPE(val)==IS_NULL) {
1895 cursor->substitution(SVAL(var),
1896 (const char *)NULL);
1897 } else {
1898 success=0;
1899 }
1900 }
1901 }
1902 RETURN_LONG(success);
1903 }
1904
ZEND_FUNCTION(sqlrcur_inputbinds)1905 DLEXPORT ZEND_FUNCTION(sqlrcur_inputbinds) {
1906 ZVAL sqlrcur;
1907 ZVAL variables;
1908 ZVAL values;
1909 ZVAL precisions;
1910 ZVAL scales;
1911 ZVAL var;
1912 ZVAL val;
1913 ZVAL precision;
1914 ZVAL scale;
1915 int i;
1916 if (ZEND_NUM_ARGS() != 3 ||
1917 GET_PARAMETERS(
1918 ZEND_NUM_ARGS() TSRMLS_CC,
1919 PARAMS("zzz")
1920 &sqlrcur,
1921 &variables,
1922 &values) == FAILURE) {
1923 if (ZEND_NUM_ARGS() != 5 ||
1924 GET_PARAMETERS(
1925 ZEND_NUM_ARGS() TSRMLS_CC,
1926 PARAMS("zzzzz")
1927 &sqlrcur,
1928 &variables,
1929 &values,
1930 &precisions,
1931 &scales)== FAILURE) {
1932 WRONG_PARAM_COUNT;
1933 } else {
1934 convert_to_array_ex(precisions);
1935 convert_to_array_ex(scales);
1936 }
1937 }
1938 convert_to_array_ex(variables);
1939 convert_to_array_ex(values);
1940 sqlrcursor *cursor=NULL;
1941 ZEND_FETCH_RESOURCE(cursor,
1942 sqlrcursor *,
1943 sqlrcur,
1944 -1,
1945 "sqlrelay cursor",
1946 sqlrelay_cursor);
1947 long success=1;
1948 if (cursor) {
1949 for (i=0; i<zend_hash_num_elements(ARRVAL(variables)); i++) {
1950 HASH_INDEX_FIND(ARRVAL(variables),i,var);
1951 HASH_INDEX_FIND(ARRVAL(values),i,val);
1952 if (TYPE(val)==IS_STRING) {
1953 convert_to_string_ex(val);
1954 cursor->inputBind(SVAL(var),
1955 SVAL(val));
1956 } else if (TYPE(val)==IS_LONG) {
1957 convert_to_long_ex(val);
1958 cursor->inputBind(SVAL(var),
1959 LVAL(val));
1960 } else if (ZEND_NUM_ARGS()==5 &&
1961 TYPE(val)==IS_DOUBLE) {
1962 HASH_INDEX_FIND(ARRVAL(precisions),i,precision);
1963 HASH_INDEX_FIND(ARRVAL(scales),i,scale);
1964 convert_to_long_ex(precision);
1965 convert_to_long_ex(scale);
1966 convert_to_double_ex(val);
1967 cursor->inputBind(
1968 SVAL(var),
1969 DVAL(val),
1970 (unsigned short)LVAL(precision),
1971 (unsigned short)LVAL(scale));
1972 } else if (TYPE(val)==IS_NULL) {
1973 cursor->inputBind(SVAL(var),
1974 (const char *)NULL);
1975 } else {
1976 success=0;
1977 }
1978 }
1979 }
1980 RETURN_LONG(success);
1981 }
1982
ZEND_FUNCTION(sqlrcur_validatebinds)1983 DLEXPORT ZEND_FUNCTION(sqlrcur_validatebinds) {
1984 ZVAL sqlrcur;
1985 if (ZEND_NUM_ARGS() != 1 ||
1986 GET_PARAMETERS(
1987 ZEND_NUM_ARGS() TSRMLS_CC,
1988 PARAMS("z")
1989 &sqlrcur) == FAILURE) {
1990 WRONG_PARAM_COUNT;
1991 }
1992 sqlrcursor *cursor=NULL;
1993 ZEND_FETCH_RESOURCE(cursor,
1994 sqlrcursor *,
1995 sqlrcur,
1996 -1,
1997 "sqlrelay cursor",
1998 sqlrelay_cursor);
1999 if (cursor) {
2000 cursor->validateBinds();
2001 }
2002 }
2003
ZEND_FUNCTION(sqlrcur_validbind)2004 DLEXPORT ZEND_FUNCTION(sqlrcur_validbind) {
2005 ZVAL sqlrcur;
2006 ZVAL variable;
2007 bool r;
2008 if (ZEND_NUM_ARGS() != 2 ||
2009 GET_PARAMETERS(
2010 ZEND_NUM_ARGS() TSRMLS_CC,
2011 PARAMS("zz")
2012 &sqlrcur,
2013 &variable) == FAILURE) {
2014 WRONG_PARAM_COUNT;
2015 }
2016 convert_to_string_ex(variable);
2017 sqlrcursor *cursor=NULL;
2018 ZEND_FETCH_RESOURCE(cursor,
2019 sqlrcursor *,
2020 sqlrcur,
2021 -1,
2022 "sqlrelay cursor",
2023 sqlrelay_cursor);
2024 if (cursor) {
2025 r=cursor->validBind(SVAL(variable));
2026 RETURN_LONG(r);
2027 }
2028 RETURN_LONG(0);
2029 }
2030
ZEND_FUNCTION(sqlrcur_executequery)2031 DLEXPORT ZEND_FUNCTION(sqlrcur_executequery) {
2032 ZVAL sqlrcur;
2033 bool r;
2034 if (ZEND_NUM_ARGS() != 1 ||
2035 GET_PARAMETERS(
2036 ZEND_NUM_ARGS() TSRMLS_CC,
2037 PARAMS("z")
2038 &sqlrcur) == FAILURE) {
2039 WRONG_PARAM_COUNT;
2040 }
2041 sqlrcursor *cursor=NULL;
2042 ZEND_FETCH_RESOURCE(cursor,
2043 sqlrcursor *,
2044 sqlrcur,
2045 -1,
2046 "sqlrelay cursor",
2047 sqlrelay_cursor);
2048 if (cursor) {
2049 r=cursor->executeQuery();
2050 RETURN_LONG(r);
2051 }
2052 RETURN_LONG(0);
2053 }
2054
ZEND_FUNCTION(sqlrcur_fetchfrombindcursor)2055 DLEXPORT ZEND_FUNCTION(sqlrcur_fetchfrombindcursor) {
2056 ZVAL sqlrcur;
2057 bool r;
2058 if (ZEND_NUM_ARGS() != 1 ||
2059 GET_PARAMETERS(
2060 ZEND_NUM_ARGS() TSRMLS_CC,
2061 PARAMS("z")
2062 &sqlrcur) == FAILURE) {
2063 WRONG_PARAM_COUNT;
2064 }
2065 sqlrcursor *cursor=NULL;
2066 ZEND_FETCH_RESOURCE(cursor,
2067 sqlrcursor *,
2068 sqlrcur,
2069 -1,
2070 "sqlrelay cursor",
2071 sqlrelay_cursor);
2072 if (cursor) {
2073 r=cursor->fetchFromBindCursor();
2074 RETURN_LONG(r);
2075 }
2076 RETURN_LONG(0);
2077 }
2078
ZEND_FUNCTION(sqlrcur_getoutputbindstring)2079 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindstring) {
2080 ZVAL sqlrcur;
2081 ZVAL variable;
2082 const char *r;
2083 uint32_t rl;
2084 if (ZEND_NUM_ARGS() != 2 ||
2085 GET_PARAMETERS(
2086 ZEND_NUM_ARGS() TSRMLS_CC,
2087 PARAMS("zz")
2088 &sqlrcur,
2089 &variable) == FAILURE) {
2090 WRONG_PARAM_COUNT;
2091 }
2092 convert_to_string_ex(variable);
2093 sqlrcursor *cursor=NULL;
2094 ZEND_FETCH_RESOURCE(cursor,
2095 sqlrcursor *,
2096 sqlrcur,
2097 -1,
2098 "sqlrelay cursor",
2099 sqlrelay_cursor);
2100 if (cursor) {
2101 r=cursor->getOutputBindString(SVAL(variable));
2102 rl=cursor->getOutputBindLength(SVAL(variable));
2103 if (r) {
2104 RET_STRINGL(const_cast<char *>(r),rl,1);
2105 }
2106 }
2107 RETURN_NULL();
2108 }
2109
ZEND_FUNCTION(sqlrcur_getoutputbindblob)2110 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindblob) {
2111 ZVAL sqlrcur;
2112 ZVAL variable;
2113 const char *r;
2114 uint32_t rl;
2115 if (ZEND_NUM_ARGS() != 2 ||
2116 GET_PARAMETERS(
2117 ZEND_NUM_ARGS() TSRMLS_CC,
2118 PARAMS("zz")
2119 &sqlrcur,
2120 &variable) == FAILURE) {
2121 WRONG_PARAM_COUNT;
2122 }
2123 convert_to_string_ex(variable);
2124 sqlrcursor *cursor=NULL;
2125 ZEND_FETCH_RESOURCE(cursor,
2126 sqlrcursor *,
2127 sqlrcur,
2128 -1,
2129 "sqlrelay cursor",
2130 sqlrelay_cursor);
2131 if (cursor) {
2132 r=cursor->getOutputBindBlob(SVAL(variable));
2133 rl=cursor->getOutputBindLength(SVAL(variable));
2134 if (r) {
2135 RET_STRINGL(const_cast<char *>(r),rl,1);
2136 }
2137 }
2138 RETURN_NULL();
2139 }
2140
ZEND_FUNCTION(sqlrcur_getoutputbindclob)2141 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindclob) {
2142 ZVAL sqlrcur;
2143 ZVAL variable;
2144 const char *r;
2145 uint32_t rl;
2146 if (ZEND_NUM_ARGS() != 2 ||
2147 GET_PARAMETERS(
2148 ZEND_NUM_ARGS() TSRMLS_CC,
2149 PARAMS("zz")
2150 &sqlrcur,
2151 &variable) == FAILURE) {
2152 WRONG_PARAM_COUNT;
2153 }
2154 convert_to_string_ex(variable);
2155 sqlrcursor *cursor=NULL;
2156 ZEND_FETCH_RESOURCE(cursor,
2157 sqlrcursor *,
2158 sqlrcur,
2159 -1,
2160 "sqlrelay cursor",
2161 sqlrelay_cursor);
2162 if (cursor) {
2163 r=cursor->getOutputBindClob(SVAL(variable));
2164 rl=cursor->getOutputBindLength(SVAL(variable));
2165 if (r) {
2166 RET_STRINGL(const_cast<char *>(r),rl,1);
2167 }
2168 }
2169 RETURN_NULL();
2170 }
2171
ZEND_FUNCTION(sqlrcur_getoutputbindinteger)2172 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindinteger) {
2173 ZVAL sqlrcur;
2174 ZVAL variable;
2175 int64_t r;
2176 if (ZEND_NUM_ARGS() != 2 ||
2177 GET_PARAMETERS(
2178 ZEND_NUM_ARGS() TSRMLS_CC,
2179 PARAMS("zz")
2180 &sqlrcur,
2181 &variable) == FAILURE) {
2182 WRONG_PARAM_COUNT;
2183 }
2184 convert_to_string_ex(variable);
2185 sqlrcursor *cursor=NULL;
2186 ZEND_FETCH_RESOURCE(cursor,
2187 sqlrcursor *,
2188 sqlrcur,
2189 -1,
2190 "sqlrelay cursor",
2191 sqlrelay_cursor);
2192 if (cursor) {
2193 r=cursor->getOutputBindInteger(SVAL(variable));
2194 RETURN_LONG(r);
2195 }
2196 RETURN_LONG(0);
2197 }
2198
ZEND_FUNCTION(sqlrcur_getoutputbinddouble)2199 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbinddouble) {
2200 ZVAL sqlrcur;
2201 ZVAL variable;
2202 double r;
2203 if (ZEND_NUM_ARGS() != 2 ||
2204 GET_PARAMETERS(
2205 ZEND_NUM_ARGS() TSRMLS_CC,
2206 PARAMS("zz")
2207 &sqlrcur,
2208 &variable) == FAILURE) {
2209 WRONG_PARAM_COUNT;
2210 }
2211 convert_to_string_ex(variable);
2212 sqlrcursor *cursor=NULL;
2213 ZEND_FETCH_RESOURCE(cursor,
2214 sqlrcursor *,
2215 sqlrcur,
2216 -1,
2217 "sqlrelay cursor",
2218 sqlrelay_cursor);
2219 if (cursor) {
2220 r=cursor->getOutputBindDouble(SVAL(variable));
2221 RETURN_DOUBLE(r);
2222 }
2223 RETURN_DOUBLE(0.0);
2224 }
2225
ZEND_FUNCTION(sqlrcur_getoutputbindlength)2226 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindlength) {
2227 ZVAL sqlrcur;
2228 ZVAL variable;
2229 uint32_t r;
2230 if (ZEND_NUM_ARGS() != 2 ||
2231 GET_PARAMETERS(
2232 ZEND_NUM_ARGS() TSRMLS_CC,
2233 PARAMS("zz")
2234 &sqlrcur,
2235 &variable) == FAILURE) {
2236 WRONG_PARAM_COUNT;
2237 }
2238 convert_to_string_ex(variable);
2239 sqlrcursor *cursor=NULL;
2240 ZEND_FETCH_RESOURCE(cursor,
2241 sqlrcursor *,
2242 sqlrcur,
2243 -1,
2244 "sqlrelay cursor",
2245 sqlrelay_cursor);
2246 if (cursor) {
2247 r=cursor->getOutputBindLength(SVAL(variable));
2248 RETURN_LONG(r);
2249 }
2250 RETURN_LONG(0);
2251 }
2252
ZEND_FUNCTION(sqlrcur_getoutputbindcursor)2253 DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindcursor) {
2254 ZVAL sqlrcur;
2255 ZVAL variable;
2256 if (ZEND_NUM_ARGS() != 2 ||
2257 GET_PARAMETERS(
2258 ZEND_NUM_ARGS() TSRMLS_CC,
2259 PARAMS("zz")
2260 &sqlrcur,
2261 &variable) == FAILURE) {
2262 WRONG_PARAM_COUNT;
2263 }
2264 convert_to_string_ex(variable);
2265 sqlrcursor *cursor=NULL;
2266 ZEND_FETCH_RESOURCE(cursor,
2267 sqlrcursor *,
2268 sqlrcur,
2269 -1,
2270 "sqlrelay cursor",
2271 sqlrelay_cursor);
2272 if (!cursor) {
2273 RETURN_LONG(0);
2274 }
2275 sqlrcursor *s=cursor->getOutputBindCursor(
2276 SVAL(variable),
2277 true);
2278 ZEND_REGISTER_RESOURCE(return_value,s,sqlrelay_cursor);
2279 }
2280
ZEND_FUNCTION(sqlrcur_opencachedresultset)2281 DLEXPORT ZEND_FUNCTION(sqlrcur_opencachedresultset) {
2282 ZVAL sqlrcur;
2283 ZVAL filename;
2284 bool r;
2285 if (ZEND_NUM_ARGS() != 2 ||
2286 GET_PARAMETERS(
2287 ZEND_NUM_ARGS() TSRMLS_CC,
2288 PARAMS("zz")
2289 &sqlrcur,
2290 &filename) == FAILURE) {
2291 WRONG_PARAM_COUNT;
2292 }
2293 convert_to_string_ex(filename);
2294 sqlrcursor *cursor=NULL;
2295 ZEND_FETCH_RESOURCE(cursor,
2296 sqlrcursor *,
2297 sqlrcur,
2298 -1,
2299 "sqlrelay cursor",
2300 sqlrelay_cursor);
2301 if (cursor) {
2302 r=cursor->openCachedResultSet(SVAL(filename));
2303 RETURN_LONG(r);
2304 }
2305 RETURN_LONG(0);
2306 }
2307
ZEND_FUNCTION(sqlrcur_colcount)2308 DLEXPORT ZEND_FUNCTION(sqlrcur_colcount) {
2309 ZVAL sqlrcur;
2310 uint32_t r;
2311 if (ZEND_NUM_ARGS() != 1 ||
2312 GET_PARAMETERS(
2313 ZEND_NUM_ARGS() TSRMLS_CC,
2314 PARAMS("z")
2315 &sqlrcur) == FAILURE) {
2316 WRONG_PARAM_COUNT;
2317 }
2318 sqlrcursor *cursor=NULL;
2319 ZEND_FETCH_RESOURCE(cursor,
2320 sqlrcursor *,
2321 sqlrcur,
2322 -1,
2323 "sqlrelay cursor",
2324 sqlrelay_cursor);
2325 if (cursor) {
2326 r=cursor->colCount();
2327 RETURN_LONG(r);
2328 }
2329 RETURN_LONG(0);
2330 }
2331
ZEND_FUNCTION(sqlrcur_rowcount)2332 DLEXPORT ZEND_FUNCTION(sqlrcur_rowcount) {
2333 ZVAL sqlrcur;
2334 uint64_t r;
2335 if (ZEND_NUM_ARGS() != 1 ||
2336 GET_PARAMETERS(
2337 ZEND_NUM_ARGS() TSRMLS_CC,
2338 PARAMS("z")
2339 &sqlrcur) == FAILURE) {
2340 WRONG_PARAM_COUNT;
2341 }
2342 sqlrcursor *cursor=NULL;
2343 ZEND_FETCH_RESOURCE(cursor,
2344 sqlrcursor *,
2345 sqlrcur,
2346 -1,
2347 "sqlrelay cursor",
2348 sqlrelay_cursor);
2349 if (cursor) {
2350 r=cursor->rowCount();
2351 RETURN_LONG(r);
2352 }
2353 RETURN_LONG(0);
2354 }
2355
ZEND_FUNCTION(sqlrcur_totalrows)2356 DLEXPORT ZEND_FUNCTION(sqlrcur_totalrows) {
2357 ZVAL sqlrcur;
2358 uint64_t r;
2359 if (ZEND_NUM_ARGS() != 1 ||
2360 GET_PARAMETERS(
2361 ZEND_NUM_ARGS() TSRMLS_CC,
2362 PARAMS("z")
2363 &sqlrcur) == FAILURE) {
2364 WRONG_PARAM_COUNT;
2365 }
2366 sqlrcursor *cursor=NULL;
2367 ZEND_FETCH_RESOURCE(cursor,
2368 sqlrcursor *,
2369 sqlrcur,
2370 -1,
2371 "sqlrelay cursor",
2372 sqlrelay_cursor);
2373 if (cursor) {
2374 r=cursor->totalRows();
2375 RETURN_LONG(r);
2376 }
2377 RETURN_LONG(0);
2378 }
2379
ZEND_FUNCTION(sqlrcur_affectedrows)2380 DLEXPORT ZEND_FUNCTION(sqlrcur_affectedrows) {
2381 ZVAL sqlrcur;
2382 uint64_t r;
2383 if (ZEND_NUM_ARGS() != 1 ||
2384 GET_PARAMETERS(
2385 ZEND_NUM_ARGS() TSRMLS_CC,
2386 PARAMS("z")
2387 &sqlrcur) == FAILURE) {
2388 WRONG_PARAM_COUNT;
2389 }
2390 sqlrcursor *cursor=NULL;
2391 ZEND_FETCH_RESOURCE(cursor,
2392 sqlrcursor *,
2393 sqlrcur,
2394 -1,
2395 "sqlrelay cursor",
2396 sqlrelay_cursor);
2397 if (cursor) {
2398 r=cursor->affectedRows();
2399 RETURN_LONG(r);
2400 }
2401 RETURN_LONG(0);
2402 }
2403
ZEND_FUNCTION(sqlrcur_firstrowindex)2404 DLEXPORT ZEND_FUNCTION(sqlrcur_firstrowindex) {
2405 ZVAL sqlrcur;
2406 uint64_t r;
2407 if (ZEND_NUM_ARGS() != 1 ||
2408 GET_PARAMETERS(
2409 ZEND_NUM_ARGS() TSRMLS_CC,
2410 PARAMS("z")
2411 &sqlrcur) == FAILURE) {
2412 WRONG_PARAM_COUNT;
2413 }
2414 sqlrcursor *cursor=NULL;
2415 ZEND_FETCH_RESOURCE(cursor,
2416 sqlrcursor *,
2417 sqlrcur,
2418 -1,
2419 "sqlrelay cursor",
2420 sqlrelay_cursor);
2421 if (cursor) {
2422 r=cursor->firstRowIndex();
2423 RETURN_LONG(r);
2424 }
2425 RETURN_LONG(0);
2426 }
2427
ZEND_FUNCTION(sqlrcur_endofresultset)2428 DLEXPORT ZEND_FUNCTION(sqlrcur_endofresultset) {
2429 ZVAL sqlrcur;
2430 bool r;
2431 if (ZEND_NUM_ARGS() != 1 ||
2432 GET_PARAMETERS(
2433 ZEND_NUM_ARGS() TSRMLS_CC,
2434 PARAMS("z")
2435 &sqlrcur) == FAILURE) {
2436 WRONG_PARAM_COUNT;
2437 }
2438 sqlrcursor *cursor=NULL;
2439 ZEND_FETCH_RESOURCE(cursor,
2440 sqlrcursor *,
2441 sqlrcur,
2442 -1,
2443 "sqlrelay cursor",
2444 sqlrelay_cursor);
2445 if (cursor) {
2446 r=cursor->endOfResultSet();
2447 RETURN_LONG(r);
2448 }
2449 RETURN_LONG(0);
2450 }
2451
ZEND_FUNCTION(sqlrcur_errormessage)2452 DLEXPORT ZEND_FUNCTION(sqlrcur_errormessage) {
2453 ZVAL sqlrcur;
2454 const char *r;
2455 if (ZEND_NUM_ARGS() != 1 ||
2456 GET_PARAMETERS(
2457 ZEND_NUM_ARGS() TSRMLS_CC,
2458 PARAMS("z")
2459 &sqlrcur) == FAILURE) {
2460 WRONG_PARAM_COUNT;
2461 }
2462 sqlrcursor *cursor=NULL;
2463 ZEND_FETCH_RESOURCE(cursor,
2464 sqlrcursor *,
2465 sqlrcur,
2466 -1,
2467 "sqlrelay cursor",
2468 sqlrelay_cursor);
2469 if (cursor) {
2470 r=cursor->errorMessage();
2471 if (r) {
2472 RET_STRING(const_cast<char *>(r),1);
2473 }
2474 }
2475 RETURN_NULL();
2476 }
2477
ZEND_FUNCTION(sqlrcur_errornumber)2478 DLEXPORT ZEND_FUNCTION(sqlrcur_errornumber) {
2479 ZVAL sqlrcur;
2480 int64_t r;
2481 if (ZEND_NUM_ARGS() != 1 ||
2482 GET_PARAMETERS(
2483 ZEND_NUM_ARGS() TSRMLS_CC,
2484 PARAMS("z")
2485 &sqlrcur) == FAILURE) {
2486 WRONG_PARAM_COUNT;
2487 }
2488 sqlrcursor *cursor=NULL;
2489 ZEND_FETCH_RESOURCE(cursor,
2490 sqlrcursor *,
2491 sqlrcur,
2492 -1,
2493 "sqlrelay cursor",
2494 sqlrelay_cursor);
2495 if (cursor) {
2496 r=cursor->errorNumber();
2497 if (r) {
2498 RETURN_LONG(r);
2499 }
2500 }
2501 RETURN_LONG(0);
2502 }
2503
ZEND_FUNCTION(sqlrcur_getnullsasemptystrings)2504 DLEXPORT ZEND_FUNCTION(sqlrcur_getnullsasemptystrings) {
2505 ZVAL sqlrcur;
2506 if (ZEND_NUM_ARGS() != 1 ||
2507 GET_PARAMETERS(
2508 ZEND_NUM_ARGS() TSRMLS_CC,
2509 PARAMS("z")
2510 &sqlrcur) == FAILURE) {
2511 WRONG_PARAM_COUNT;
2512 }
2513 sqlrcursor *cursor=NULL;
2514 ZEND_FETCH_RESOURCE(cursor,
2515 sqlrcursor *,
2516 sqlrcur,
2517 -1,
2518 "sqlrelay cursor",
2519 sqlrelay_cursor);
2520 if (cursor) {
2521 cursor->getNullsAsEmptyStrings();
2522 }
2523 }
2524
ZEND_FUNCTION(sqlrcur_getnullsasnulls)2525 DLEXPORT ZEND_FUNCTION(sqlrcur_getnullsasnulls) {
2526 ZVAL sqlrcur;
2527 if (ZEND_NUM_ARGS() != 1 ||
2528 GET_PARAMETERS(
2529 ZEND_NUM_ARGS() TSRMLS_CC,
2530 PARAMS("z")
2531 &sqlrcur) == FAILURE) {
2532 WRONG_PARAM_COUNT;
2533 }
2534 sqlrcursor *cursor=NULL;
2535 ZEND_FETCH_RESOURCE(cursor,
2536 sqlrcursor *,
2537 sqlrcur,
2538 -1,
2539 "sqlrelay cursor",
2540 sqlrelay_cursor);
2541 if (cursor) {
2542 cursor->getNullsAsNulls();
2543 }
2544 }
2545
ZEND_FUNCTION(sqlrcur_getfield)2546 DLEXPORT ZEND_FUNCTION(sqlrcur_getfield) {
2547 ZVAL sqlrcur;
2548 ZVAL row;
2549 ZVAL col;
2550 const char *r=NULL;
2551 uint32_t rl;
2552 if (ZEND_NUM_ARGS() != 3 ||
2553 GET_PARAMETERS(
2554 ZEND_NUM_ARGS() TSRMLS_CC,
2555 PARAMS("zzz")
2556 &sqlrcur,
2557 &row,
2558 &col) == FAILURE) {
2559 WRONG_PARAM_COUNT;
2560 }
2561 convert_to_long_ex(row);
2562 sqlrcursor *cursor=NULL;
2563 ZEND_FETCH_RESOURCE(cursor,
2564 sqlrcursor *,
2565 sqlrcur,
2566 -1,
2567 "sqlrelay cursor",
2568 sqlrelay_cursor);
2569 if (cursor) {
2570 if (TYPE(col)==IS_LONG) {
2571 convert_to_long_ex(col);
2572 r=cursor->getField(LVAL(row),LVAL(col));
2573 rl=cursor->getFieldLength(LVAL(row),LVAL(col));
2574 } else if (TYPE(col)==IS_STRING) {
2575 convert_to_string_ex(col);
2576 r=cursor->getField(LVAL(row),
2577 SVAL(col));
2578 rl=cursor->getFieldLength(LVAL(row),
2579 SVAL(col));
2580 }
2581 if (r) {
2582 RET_STRINGL(const_cast<char *>(r),rl,1);
2583 }
2584 }
2585 RETURN_NULL();
2586 }
2587
ZEND_FUNCTION(sqlrcur_getfieldasinteger)2588 DLEXPORT ZEND_FUNCTION(sqlrcur_getfieldasinteger) {
2589 ZVAL sqlrcur;
2590 ZVAL row;
2591 ZVAL col;
2592 int64_t r=0;
2593 if (ZEND_NUM_ARGS() != 3 ||
2594 GET_PARAMETERS(
2595 ZEND_NUM_ARGS() TSRMLS_CC,
2596 PARAMS("zzz")
2597 &sqlrcur,
2598 &row,
2599 &col) == FAILURE) {
2600 WRONG_PARAM_COUNT;
2601 }
2602 convert_to_long_ex(row);
2603 sqlrcursor *cursor=NULL;
2604 ZEND_FETCH_RESOURCE(cursor,
2605 sqlrcursor *,
2606 sqlrcur,
2607 -1,
2608 "sqlrelay cursor",
2609 sqlrelay_cursor);
2610 if (cursor) {
2611 if (TYPE(col)==IS_LONG) {
2612 convert_to_long_ex(col);
2613 r=cursor->getFieldAsInteger(LVAL(row),
2614 LVAL(col));
2615 } else if (TYPE(col)==IS_STRING) {
2616 convert_to_string_ex(col);
2617 r=cursor->getFieldAsInteger(LVAL(row),
2618 SVAL(col));
2619 }
2620 RETURN_LONG(r);
2621 }
2622 RETURN_LONG(0);
2623 }
2624
ZEND_FUNCTION(sqlrcur_getfieldasdouble)2625 DLEXPORT ZEND_FUNCTION(sqlrcur_getfieldasdouble) {
2626 ZVAL sqlrcur;
2627 ZVAL row;
2628 ZVAL col;
2629 double r=0.0;
2630 if (ZEND_NUM_ARGS() != 3 ||
2631 GET_PARAMETERS(
2632 ZEND_NUM_ARGS() TSRMLS_CC,
2633 PARAMS("zzz")
2634 &sqlrcur,
2635 &row,
2636 &col) == FAILURE) {
2637 WRONG_PARAM_COUNT;
2638 }
2639 convert_to_long_ex(row);
2640 sqlrcursor *cursor=NULL;
2641 ZEND_FETCH_RESOURCE(cursor,
2642 sqlrcursor *,
2643 sqlrcur,
2644 -1,
2645 "sqlrelay cursor",
2646 sqlrelay_cursor);
2647 if (cursor) {
2648 if (TYPE(col)==IS_LONG) {
2649 convert_to_long_ex(col);
2650 r=cursor->getFieldAsDouble(LVAL(row),
2651 LVAL(col));
2652 } else if (TYPE(col)==IS_STRING) {
2653 convert_to_string_ex(col);
2654 r=cursor->getFieldAsDouble(LVAL(row),
2655 SVAL(col));
2656 }
2657 RETURN_DOUBLE(r);
2658 }
2659 RETURN_DOUBLE(0.0);
2660 }
2661
ZEND_FUNCTION(sqlrcur_getfieldlength)2662 DLEXPORT ZEND_FUNCTION(sqlrcur_getfieldlength) {
2663 ZVAL sqlrcur;
2664 ZVAL row;
2665 ZVAL col;
2666 uint32_t r=0;
2667 if (ZEND_NUM_ARGS() != 3 ||
2668 GET_PARAMETERS(
2669 ZEND_NUM_ARGS() TSRMLS_CC,
2670 PARAMS("zzz")
2671 &sqlrcur,
2672 &row,
2673 &col) == FAILURE) {
2674 WRONG_PARAM_COUNT;
2675 }
2676 convert_to_long_ex(row);
2677 sqlrcursor *cursor=NULL;
2678 ZEND_FETCH_RESOURCE(cursor,
2679 sqlrcursor *,
2680 sqlrcur,
2681 -1,
2682 "sqlrelay cursor",
2683 sqlrelay_cursor);
2684 if (cursor) {
2685 if (TYPE(col)==IS_LONG) {
2686 convert_to_long_ex(col);
2687 r=cursor->getFieldLength(LVAL(row),
2688 LVAL(col));
2689 } else if (TYPE(col)==IS_STRING) {
2690 convert_to_string_ex(col);
2691 r=cursor->getFieldLength(LVAL(row),
2692 SVAL(col));
2693 }
2694 RETURN_LONG(r);
2695 }
2696 RETURN_LONG(0);
2697 }
2698
ZEND_FUNCTION(sqlrcur_getrow)2699 DLEXPORT ZEND_FUNCTION(sqlrcur_getrow) {
2700 ZVAL sqlrcur;
2701 ZVAL row;
2702 const char * const *r;
2703 uint32_t *l;
2704 uint32_t i;
2705 if (ZEND_NUM_ARGS() != 2 ||
2706 GET_PARAMETERS(
2707 ZEND_NUM_ARGS() TSRMLS_CC,
2708 PARAMS("zz")
2709 &sqlrcur,
2710 &row) == FAILURE) {
2711 WRONG_PARAM_COUNT;
2712 }
2713 convert_to_long_ex(row);
2714 sqlrcursor *cursor=NULL;
2715 ZEND_FETCH_RESOURCE(cursor,
2716 sqlrcursor *,
2717 sqlrcur,
2718 -1,
2719 "sqlrelay cursor",
2720 sqlrelay_cursor);
2721 if (!cursor) {
2722 RETURN_FALSE;
2723 }
2724 r=cursor->getRow(LVAL(row));
2725 l=cursor->getRowLengths(LVAL(row));
2726 if (!r) {
2727 RETURN_FALSE;
2728 }
2729 #ifdef ARRAY_INIT_CANT_FAIL
2730 array_init(return_value);
2731 #else
2732 if (array_init(return_value) == FAILURE) {
2733 RETURN_FALSE;
2734 }
2735 #endif
2736 for (i=0; i<cursor->colCount(); i++) {
2737 if (!r[i]) {
2738 ADD_NEXT_INDEX_NULL(return_value);
2739 } else {
2740 ADD_NEXT_INDEX_STRINGL(return_value,
2741 const_cast<char *>(r[i]),
2742 l[i],
2743 1);
2744 }
2745 }
2746 }
2747
ZEND_FUNCTION(sqlrcur_getrowassoc)2748 DLEXPORT ZEND_FUNCTION(sqlrcur_getrowassoc) {
2749 ZVAL sqlrcur;
2750 ZVAL row;
2751 const char * const *r;
2752 uint32_t *l;
2753 const char * const *rC;
2754 uint32_t i;
2755 if (ZEND_NUM_ARGS() != 2 ||
2756 GET_PARAMETERS(
2757 ZEND_NUM_ARGS() TSRMLS_CC,
2758 PARAMS("zz")
2759 &sqlrcur,
2760 &row) == FAILURE) {
2761 WRONG_PARAM_COUNT;
2762 }
2763
2764 convert_to_long_ex(row);
2765
2766 sqlrcursor *cursor=NULL;
2767 ZEND_FETCH_RESOURCE(cursor,
2768 sqlrcursor *,
2769 sqlrcur,
2770 -1,
2771 "sqlrelay cursor",
2772 sqlrelay_cursor);
2773 if (!cursor) {
2774 RETURN_FALSE;
2775 }
2776
2777 rC=cursor->getColumnNames();
2778 if (!rC) {
2779 RETURN_FALSE;
2780 }
2781
2782 r=cursor->getRow(LVAL(row));
2783 l=cursor->getRowLengths(LVAL(row));
2784 if (!r) {
2785 RETURN_FALSE;
2786 }
2787 #ifdef ARRAY_INIT_CANT_FAIL
2788 array_init(return_value);
2789 #else
2790 if (array_init(return_value) == FAILURE) {
2791 RETURN_FALSE;
2792 }
2793 #endif
2794 for (i=0; i<cursor->colCount(); i++) {
2795 if (!r[i]) {
2796 ADD_ASSOC_NULL(return_value,const_cast<char *>(rC[i]));
2797 } else {
2798 ADD_ASSOC_STRINGL(return_value,
2799 const_cast<char *>(rC[i]),
2800 const_cast<char *>(r[i]),
2801 l[i],
2802 1);
2803 }
2804 }
2805 }
2806
ZEND_FUNCTION(sqlrcur_getrowlengths)2807 DLEXPORT ZEND_FUNCTION(sqlrcur_getrowlengths) {
2808 ZVAL sqlrcur;
2809 ZVAL row;
2810 uint32_t *r;
2811 uint32_t i;
2812 if (ZEND_NUM_ARGS() != 2 ||
2813 GET_PARAMETERS(
2814 ZEND_NUM_ARGS() TSRMLS_CC,
2815 PARAMS("zz")
2816 &sqlrcur,
2817 &row) == FAILURE) {
2818 WRONG_PARAM_COUNT;
2819 }
2820 convert_to_long_ex(row);
2821 sqlrcursor *cursor=NULL;
2822 ZEND_FETCH_RESOURCE(cursor,
2823 sqlrcursor *,
2824 sqlrcur,
2825 -1,
2826 "sqlrelay cursor",
2827 sqlrelay_cursor);
2828 if (!cursor) {
2829 RETURN_FALSE;
2830 }
2831 r=cursor->getRowLengths(LVAL(row));
2832 if (!r) {
2833 RETURN_FALSE;
2834 }
2835 #ifdef ARRAY_INIT_CANT_FAIL
2836 array_init(return_value);
2837 #else
2838 if (array_init(return_value) == FAILURE) {
2839 RETURN_FALSE;
2840 }
2841 #endif
2842 for (i=0; i<cursor->colCount(); i++) {
2843 add_next_index_long(return_value,r[i]);
2844 }
2845 }
2846
ZEND_FUNCTION(sqlrcur_getrowlengthsassoc)2847 DLEXPORT ZEND_FUNCTION(sqlrcur_getrowlengthsassoc) {
2848 ZVAL sqlrcur;
2849 ZVAL row;
2850 uint32_t *r;
2851 const char * const *rC;
2852 uint32_t i;
2853 if (ZEND_NUM_ARGS() != 2 ||
2854 GET_PARAMETERS(
2855 ZEND_NUM_ARGS() TSRMLS_CC,
2856 PARAMS("zz")
2857 &sqlrcur,
2858 &row) == FAILURE) {
2859 WRONG_PARAM_COUNT;
2860 }
2861
2862 convert_to_long_ex(row);
2863
2864 sqlrcursor *cursor=NULL;
2865 ZEND_FETCH_RESOURCE(cursor,
2866 sqlrcursor *,
2867 sqlrcur,
2868 -1,
2869 "sqlrelay cursor",
2870 sqlrelay_cursor);
2871 if (!cursor) {
2872 RETURN_FALSE;
2873 }
2874
2875 rC=cursor->getColumnNames();
2876 if (!rC) {
2877 RETURN_FALSE;
2878 }
2879
2880 r=cursor->getRowLengths(LVAL(row));
2881 if (!r) {
2882 RETURN_FALSE;
2883 }
2884 #ifdef ARRAY_INIT_CANT_FAIL
2885 array_init(return_value);
2886 #else
2887 if (array_init(return_value) == FAILURE) {
2888 RETURN_FALSE;
2889 }
2890 #endif
2891 for (i=0; i<cursor->colCount(); i++) {
2892 add_assoc_long(return_value,const_cast<char *>(rC[i]),r[i]);
2893 }
2894 }
2895
ZEND_FUNCTION(sqlrcur_getcolumnnames)2896 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnnames) {
2897 ZVAL sqlrcur;
2898 const char * const *r;
2899 uint32_t i;
2900 if (ZEND_NUM_ARGS() != 1 ||
2901 GET_PARAMETERS(
2902 ZEND_NUM_ARGS() TSRMLS_CC,
2903 PARAMS("z")
2904 &sqlrcur) == FAILURE) {
2905 WRONG_PARAM_COUNT;
2906 }
2907 sqlrcursor *cursor=NULL;
2908 ZEND_FETCH_RESOURCE(cursor,
2909 sqlrcursor *,
2910 sqlrcur,
2911 -1,
2912 "sqlrelay cursor",
2913 sqlrelay_cursor);
2914 if (!cursor) {
2915 RETURN_FALSE;
2916 }
2917 r=cursor->getColumnNames();
2918 if (!r) {
2919 RETURN_FALSE;
2920 }
2921 #ifdef ARRAY_INIT_CANT_FAIL
2922 array_init(return_value);
2923 #else
2924 if (array_init(return_value) == FAILURE) {
2925 RETURN_FALSE;
2926 }
2927 #endif
2928 for (i=0; i<cursor->colCount(); i++) {
2929 ADD_NEXT_INDEX_STRING(return_value,const_cast<char *>(r[i]),1);
2930 }
2931 }
2932
ZEND_FUNCTION(sqlrcur_getcolumnname)2933 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnname) {
2934 ZVAL sqlrcur;
2935 ZVAL col;
2936 const char *r;
2937 if (ZEND_NUM_ARGS() != 2 ||
2938 GET_PARAMETERS(
2939 ZEND_NUM_ARGS() TSRMLS_CC,
2940 PARAMS("zz")
2941 &sqlrcur,
2942 &col) == FAILURE) {
2943 WRONG_PARAM_COUNT;
2944 }
2945 convert_to_long_ex(col);
2946 sqlrcursor *cursor=NULL;
2947 ZEND_FETCH_RESOURCE(cursor,
2948 sqlrcursor *,
2949 sqlrcur,
2950 -1,
2951 "sqlrelay cursor",
2952 sqlrelay_cursor);
2953 if (cursor) {
2954 r=cursor->getColumnName(LVAL(col));
2955 if (r) {
2956 RET_STRING(const_cast<char *>(r),1);
2957 }
2958 }
2959 RETURN_FALSE;
2960 }
2961
ZEND_FUNCTION(sqlrcur_getcolumntype)2962 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumntype) {
2963 ZVAL sqlrcur;
2964 ZVAL col;
2965 const char *r=NULL;
2966 if (ZEND_NUM_ARGS() != 2 ||
2967 GET_PARAMETERS(
2968 ZEND_NUM_ARGS() TSRMLS_CC,
2969 PARAMS("zz")
2970 &sqlrcur,
2971 &col) == FAILURE) {
2972 WRONG_PARAM_COUNT;
2973 }
2974 sqlrcursor *cursor=NULL;
2975 ZEND_FETCH_RESOURCE(cursor,
2976 sqlrcursor *,
2977 sqlrcur,
2978 -1,
2979 "sqlrelay cursor",
2980 sqlrelay_cursor);
2981 if (cursor) {
2982 if (TYPE(col)==IS_LONG) {
2983 convert_to_long_ex(col);
2984 r=cursor->getColumnType(LVAL(col));
2985 } else if (TYPE(col)==IS_STRING) {
2986 convert_to_string_ex(col);
2987 r=cursor->getColumnType(SVAL(col));
2988 }
2989 if (r) {
2990 RET_STRING(const_cast<char *>(r),1);
2991 }
2992 }
2993 RETURN_FALSE;
2994 }
2995
ZEND_FUNCTION(sqlrcur_getcolumnlength)2996 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnlength) {
2997 ZVAL sqlrcur;
2998 ZVAL col;
2999 uint32_t r=0;
3000 if (ZEND_NUM_ARGS() != 2 ||
3001 GET_PARAMETERS(
3002 ZEND_NUM_ARGS() TSRMLS_CC,
3003 PARAMS("zz")
3004 &sqlrcur,
3005 &col) == FAILURE) {
3006 WRONG_PARAM_COUNT;
3007 }
3008 sqlrcursor *cursor=NULL;
3009 ZEND_FETCH_RESOURCE(cursor,
3010 sqlrcursor *,
3011 sqlrcur,
3012 -1,
3013 "sqlrelay cursor",
3014 sqlrelay_cursor);
3015 if (cursor) {
3016 if (TYPE(col)==IS_LONG) {
3017 convert_to_long_ex(col);
3018 r=cursor->getColumnLength(LVAL(col));
3019 } else if (TYPE(col)==IS_STRING) {
3020 convert_to_string_ex(col);
3021 r=cursor->getColumnLength(SVAL(col));
3022 }
3023 RETURN_LONG(r);
3024 }
3025 RETURN_LONG(0);
3026 }
3027
ZEND_FUNCTION(sqlrcur_getcolumnprecision)3028 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnprecision) {
3029 ZVAL sqlrcur;
3030 ZVAL col;
3031 uint32_t r=0;
3032 if (ZEND_NUM_ARGS() != 2 ||
3033 GET_PARAMETERS(
3034 ZEND_NUM_ARGS() TSRMLS_CC,
3035 PARAMS("zz")
3036 &sqlrcur,
3037 &col) == FAILURE) {
3038 WRONG_PARAM_COUNT;
3039 }
3040 sqlrcursor *cursor=NULL;
3041 ZEND_FETCH_RESOURCE(cursor,
3042 sqlrcursor *,
3043 sqlrcur,
3044 -1,
3045 "sqlrelay cursor",
3046 sqlrelay_cursor);
3047 if (cursor) {
3048 if (TYPE(col)==IS_LONG) {
3049 convert_to_long_ex(col);
3050 r=cursor->getColumnPrecision(LVAL(col));
3051 } else if (TYPE(col)==IS_STRING) {
3052 convert_to_string_ex(col);
3053 r=cursor->getColumnPrecision(SVAL(col));
3054 }
3055 RETURN_LONG(r);
3056 }
3057 RETURN_LONG(0);
3058 }
3059
ZEND_FUNCTION(sqlrcur_getcolumnscale)3060 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnscale) {
3061 ZVAL sqlrcur;
3062 ZVAL col;
3063 uint32_t r=0;
3064 if (ZEND_NUM_ARGS() != 2 ||
3065 GET_PARAMETERS(
3066 ZEND_NUM_ARGS() TSRMLS_CC,
3067 PARAMS("zz")
3068 &sqlrcur,
3069 &col) == FAILURE) {
3070 WRONG_PARAM_COUNT;
3071 }
3072 sqlrcursor *cursor=NULL;
3073 ZEND_FETCH_RESOURCE(cursor,
3074 sqlrcursor *,
3075 sqlrcur,
3076 -1,
3077 "sqlrelay cursor",
3078 sqlrelay_cursor);
3079 if (cursor) {
3080 if (TYPE(col)==IS_LONG) {
3081 convert_to_long_ex(col);
3082 r=cursor->getColumnScale(LVAL(col));
3083 } else if (TYPE(col)==IS_STRING) {
3084 convert_to_string_ex(col);
3085 r=cursor->getColumnScale(SVAL(col));
3086 }
3087 RETURN_LONG(r);
3088 }
3089 RETURN_LONG(0);
3090 }
3091
ZEND_FUNCTION(sqlrcur_getcolumnisnullable)3092 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisnullable) {
3093 ZVAL sqlrcur;
3094 ZVAL col;
3095 bool r=0;
3096 if (ZEND_NUM_ARGS() != 2 ||
3097 GET_PARAMETERS(
3098 ZEND_NUM_ARGS() TSRMLS_CC,
3099 PARAMS("zz")
3100 &sqlrcur,
3101 &col) == FAILURE) {
3102 WRONG_PARAM_COUNT;
3103 }
3104 sqlrcursor *cursor=NULL;
3105 ZEND_FETCH_RESOURCE(cursor,
3106 sqlrcursor *,
3107 sqlrcur,
3108 -1,
3109 "sqlrelay cursor",
3110 sqlrelay_cursor);
3111 if (cursor) {
3112 if (TYPE(col)==IS_LONG) {
3113 convert_to_long_ex(col);
3114 r=cursor->getColumnIsNullable(LVAL(col));
3115 } else if (TYPE(col)==IS_STRING) {
3116 convert_to_string_ex(col);
3117 r=cursor->getColumnIsNullable(SVAL(col));
3118 }
3119 RETURN_LONG(r);
3120 }
3121 RETURN_LONG(0);
3122 }
3123
ZEND_FUNCTION(sqlrcur_getcolumnisprimarykey)3124 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisprimarykey) {
3125 ZVAL sqlrcur;
3126 ZVAL col;
3127 bool r=0;
3128 if (ZEND_NUM_ARGS() != 2 ||
3129 GET_PARAMETERS(
3130 ZEND_NUM_ARGS() TSRMLS_CC,
3131 PARAMS("zz")
3132 &sqlrcur,
3133 &col) == FAILURE) {
3134 WRONG_PARAM_COUNT;
3135 }
3136 sqlrcursor *cursor=NULL;
3137 ZEND_FETCH_RESOURCE(cursor,
3138 sqlrcursor *,
3139 sqlrcur,
3140 -1,
3141 "sqlrelay cursor",
3142 sqlrelay_cursor);
3143 if (cursor) {
3144 if (TYPE(col)==IS_LONG) {
3145 convert_to_long_ex(col);
3146 r=cursor->getColumnIsPrimaryKey(LVAL(col));
3147 } else if (TYPE(col)==IS_STRING) {
3148 convert_to_string_ex(col);
3149 r=cursor->getColumnIsPrimaryKey(SVAL(col));
3150 }
3151 RETURN_LONG(r);
3152 }
3153 RETURN_LONG(0);
3154 }
3155
ZEND_FUNCTION(sqlrcur_getcolumnisunique)3156 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisunique) {
3157 ZVAL sqlrcur;
3158 ZVAL col;
3159 bool r=0;
3160 if (ZEND_NUM_ARGS() != 2 ||
3161 GET_PARAMETERS(
3162 ZEND_NUM_ARGS() TSRMLS_CC,
3163 PARAMS("zz")
3164 &sqlrcur,
3165 &col) == FAILURE) {
3166 WRONG_PARAM_COUNT;
3167 }
3168 sqlrcursor *cursor=NULL;
3169 ZEND_FETCH_RESOURCE(cursor,
3170 sqlrcursor *,
3171 sqlrcur,
3172 -1,
3173 "sqlrelay cursor",
3174 sqlrelay_cursor);
3175 if (cursor) {
3176 if (TYPE(col)==IS_LONG) {
3177 convert_to_long_ex(col);
3178 r=cursor->getColumnIsUnique(LVAL(col));
3179 } else if (TYPE(col)==IS_STRING) {
3180 convert_to_string_ex(col);
3181 r=cursor->getColumnIsUnique(SVAL(col));
3182 }
3183 RETURN_LONG(r);
3184 }
3185 RETURN_LONG(0);
3186 }
3187
ZEND_FUNCTION(sqlrcur_getcolumnispartofkey)3188 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnispartofkey) {
3189 ZVAL sqlrcur;
3190 ZVAL col;
3191 bool r=0;
3192 if (ZEND_NUM_ARGS() != 2 ||
3193 GET_PARAMETERS(
3194 ZEND_NUM_ARGS() TSRMLS_CC,
3195 PARAMS("zz")
3196 &sqlrcur,
3197 &col) == FAILURE) {
3198 WRONG_PARAM_COUNT;
3199 }
3200 sqlrcursor *cursor=NULL;
3201 ZEND_FETCH_RESOURCE(cursor,
3202 sqlrcursor *,
3203 sqlrcur,
3204 -1,
3205 "sqlrelay cursor",
3206 sqlrelay_cursor);
3207 if (cursor) {
3208 if (TYPE(col)==IS_LONG) {
3209 convert_to_long_ex(col);
3210 r=cursor->getColumnIsPartOfKey(LVAL(col));
3211 } else if (TYPE(col)==IS_STRING) {
3212 convert_to_string_ex(col);
3213 r=cursor->getColumnIsPartOfKey(SVAL(col));
3214 }
3215 RETURN_LONG(r);
3216 }
3217 RETURN_LONG(0);
3218 }
3219
ZEND_FUNCTION(sqlrcur_getcolumnisunsigned)3220 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisunsigned) {
3221 ZVAL sqlrcur;
3222 ZVAL col;
3223 bool r=0;
3224 if (ZEND_NUM_ARGS() != 2 ||
3225 GET_PARAMETERS(
3226 ZEND_NUM_ARGS() TSRMLS_CC,
3227 PARAMS("zz")
3228 &sqlrcur,
3229 &col) == FAILURE) {
3230 WRONG_PARAM_COUNT;
3231 }
3232 sqlrcursor *cursor=NULL;
3233 ZEND_FETCH_RESOURCE(cursor,
3234 sqlrcursor *,
3235 sqlrcur,
3236 -1,
3237 "sqlrelay cursor",
3238 sqlrelay_cursor);
3239 if (cursor) {
3240 if (TYPE(col)==IS_LONG) {
3241 convert_to_long_ex(col);
3242 r=cursor->getColumnIsUnsigned(LVAL(col));
3243 } else if (TYPE(col)==IS_STRING) {
3244 convert_to_string_ex(col);
3245 r=cursor->getColumnIsUnsigned(SVAL(col));
3246 }
3247 RETURN_LONG(r);
3248 }
3249 RETURN_LONG(0);
3250 }
3251
ZEND_FUNCTION(sqlrcur_getcolumniszerofilled)3252 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumniszerofilled) {
3253 ZVAL sqlrcur;
3254 ZVAL col;
3255 bool r=0;
3256 if (ZEND_NUM_ARGS() != 2 ||
3257 GET_PARAMETERS(
3258 ZEND_NUM_ARGS() TSRMLS_CC,
3259 PARAMS("zz")
3260 &sqlrcur,
3261 &col) == FAILURE) {
3262 WRONG_PARAM_COUNT;
3263 }
3264 sqlrcursor *cursor=NULL;
3265 ZEND_FETCH_RESOURCE(cursor,
3266 sqlrcursor *,
3267 sqlrcur,
3268 -1,
3269 "sqlrelay cursor",
3270 sqlrelay_cursor);
3271 if (cursor) {
3272 if (TYPE(col)==IS_LONG) {
3273 convert_to_long_ex(col);
3274 r=cursor->getColumnIsZeroFilled(LVAL(col));
3275 } else if (TYPE(col)==IS_STRING) {
3276 convert_to_string_ex(col);
3277 r=cursor->getColumnIsZeroFilled(SVAL(col));
3278 }
3279 RETURN_LONG(r);
3280 }
3281 RETURN_LONG(0);
3282 }
3283
ZEND_FUNCTION(sqlrcur_getcolumnisbinary)3284 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisbinary) {
3285 ZVAL sqlrcur;
3286 ZVAL col;
3287 bool r=0;
3288 if (ZEND_NUM_ARGS() != 2 ||
3289 GET_PARAMETERS(
3290 ZEND_NUM_ARGS() TSRMLS_CC,
3291 PARAMS("zz")
3292 &sqlrcur,
3293 &col) == FAILURE) {
3294 WRONG_PARAM_COUNT;
3295 }
3296 sqlrcursor *cursor=NULL;
3297 ZEND_FETCH_RESOURCE(cursor,
3298 sqlrcursor *,
3299 sqlrcur,
3300 -1,
3301 "sqlrelay cursor",
3302 sqlrelay_cursor);
3303 if (cursor) {
3304 if (TYPE(col)==IS_LONG) {
3305 convert_to_long_ex(col);
3306 r=cursor->getColumnIsBinary(LVAL(col));
3307 } else if (TYPE(col)==IS_STRING) {
3308 convert_to_string_ex(col);
3309 r=cursor->getColumnIsBinary(SVAL(col));
3310 }
3311 RETURN_LONG(r);
3312 }
3313 RETURN_LONG(0);
3314 }
3315
ZEND_FUNCTION(sqlrcur_getcolumnisautoincrement)3316 DLEXPORT ZEND_FUNCTION(sqlrcur_getcolumnisautoincrement) {
3317 ZVAL sqlrcur;
3318 ZVAL col;
3319 bool r=0;
3320 if (ZEND_NUM_ARGS() != 2 ||
3321 GET_PARAMETERS(
3322 ZEND_NUM_ARGS() TSRMLS_CC,
3323 PARAMS("zz")
3324 &sqlrcur,
3325 &col) == FAILURE) {
3326 WRONG_PARAM_COUNT;
3327 }
3328 sqlrcursor *cursor=NULL;
3329 ZEND_FETCH_RESOURCE(cursor,
3330 sqlrcursor *,
3331 sqlrcur,
3332 -1,
3333 "sqlrelay cursor",
3334 sqlrelay_cursor);
3335 if (cursor) {
3336 if (TYPE(col)==IS_LONG) {
3337 convert_to_long_ex(col);
3338 r=cursor->getColumnIsAutoIncrement(LVAL(col));
3339 } else if (TYPE(col)==IS_STRING) {
3340 convert_to_string_ex(col);
3341 r=cursor->getColumnIsAutoIncrement(SVAL(col));
3342 }
3343 RETURN_LONG(r);
3344 }
3345 RETURN_LONG(0);
3346 }
3347
ZEND_FUNCTION(sqlrcur_getlongest)3348 DLEXPORT ZEND_FUNCTION(sqlrcur_getlongest) {
3349 ZVAL sqlrcur;
3350 ZVAL col;
3351 uint32_t r=0;
3352 if (ZEND_NUM_ARGS() != 2 ||
3353 GET_PARAMETERS(
3354 ZEND_NUM_ARGS() TSRMLS_CC,
3355 PARAMS("zz")
3356 &sqlrcur,
3357 &col) == FAILURE) {
3358 WRONG_PARAM_COUNT;
3359 }
3360 sqlrcursor *cursor=NULL;
3361 ZEND_FETCH_RESOURCE(cursor,
3362 sqlrcursor *,
3363 sqlrcur,
3364 -1,
3365 "sqlrelay cursor",
3366 sqlrelay_cursor);
3367 if (cursor) {
3368 if (TYPE(col)==IS_LONG) {
3369 convert_to_long_ex(col);
3370 r=cursor->getLongest(LVAL(col));
3371 } else if (TYPE(col)==IS_STRING) {
3372 convert_to_string_ex(col);
3373 r=cursor->getLongest(SVAL(col));
3374 }
3375 RETURN_LONG(r);
3376 }
3377 RETURN_LONG(0);
3378 }
3379
ZEND_FUNCTION(sqlrcur_getresultsetid)3380 DLEXPORT ZEND_FUNCTION(sqlrcur_getresultsetid) {
3381 ZVAL sqlrcur;
3382 uint16_t r;
3383 if (ZEND_NUM_ARGS() != 1 ||
3384 GET_PARAMETERS(
3385 ZEND_NUM_ARGS() TSRMLS_CC,
3386 PARAMS("z")
3387 &sqlrcur) == FAILURE) {
3388 WRONG_PARAM_COUNT;
3389 }
3390 sqlrcursor *cursor=NULL;
3391 ZEND_FETCH_RESOURCE(cursor,
3392 sqlrcursor *,
3393 sqlrcur,
3394 -1,
3395 "sqlrelay cursor",
3396 sqlrelay_cursor);
3397 if (cursor) {
3398 r=cursor->getResultSetId();
3399 RETURN_LONG(r);
3400 }
3401 RETURN_LONG(0);
3402 }
3403
ZEND_FUNCTION(sqlrcur_suspendresultset)3404 DLEXPORT ZEND_FUNCTION(sqlrcur_suspendresultset) {
3405 ZVAL sqlrcur;
3406 if (ZEND_NUM_ARGS() != 1 ||
3407 GET_PARAMETERS(
3408 ZEND_NUM_ARGS() TSRMLS_CC,
3409 PARAMS("z")
3410 &sqlrcur) == FAILURE) {
3411 WRONG_PARAM_COUNT;
3412 }
3413 sqlrcursor *cursor=NULL;
3414 ZEND_FETCH_RESOURCE(cursor,
3415 sqlrcursor *,
3416 sqlrcur,
3417 -1,
3418 "sqlrelay cursor",
3419 sqlrelay_cursor);
3420 if (cursor) {
3421 cursor->suspendResultSet();
3422 }
3423 }
3424
ZEND_FUNCTION(sqlrcur_resumeresultset)3425 DLEXPORT ZEND_FUNCTION(sqlrcur_resumeresultset) {
3426 ZVAL sqlrcur;
3427 ZVAL id;
3428 bool r;
3429 if (ZEND_NUM_ARGS() != 2 ||
3430 GET_PARAMETERS(
3431 ZEND_NUM_ARGS() TSRMLS_CC,
3432 PARAMS("zz")
3433 &sqlrcur,
3434 &id) == FAILURE) {
3435 WRONG_PARAM_COUNT;
3436 }
3437 convert_to_long_ex(id);
3438 sqlrcursor *cursor=NULL;
3439 ZEND_FETCH_RESOURCE(cursor,
3440 sqlrcursor *,
3441 sqlrcur,
3442 -1,
3443 "sqlrelay cursor",
3444 sqlrelay_cursor);
3445 if (cursor) {
3446 r=cursor->resumeResultSet(LVAL(id));
3447 RETURN_LONG(r);
3448 }
3449 RETURN_LONG(0);
3450 }
3451
ZEND_FUNCTION(sqlrcur_resumecachedresultset)3452 DLEXPORT ZEND_FUNCTION(sqlrcur_resumecachedresultset) {
3453 ZVAL sqlrcur;
3454 ZVAL id;
3455 ZVAL filename;
3456 bool r;
3457 if (ZEND_NUM_ARGS() != 3 ||
3458 GET_PARAMETERS(
3459 ZEND_NUM_ARGS() TSRMLS_CC,
3460 PARAMS("zzz")
3461 &sqlrcur,
3462 &id,
3463 &filename) == FAILURE) {
3464 WRONG_PARAM_COUNT;
3465 }
3466 convert_to_long_ex(id);
3467 convert_to_string_ex(filename);
3468 sqlrcursor *cursor=NULL;
3469 ZEND_FETCH_RESOURCE(cursor,
3470 sqlrcursor *,
3471 sqlrcur,
3472 -1,
3473 "sqlrelay cursor",
3474 sqlrelay_cursor);
3475 if (cursor) {
3476 r=cursor->resumeCachedResultSet(LVAL(id),
3477 SVAL(filename));
3478 RETURN_LONG(r);
3479 }
3480 RETURN_LONG(0);
3481 }
3482
ZEND_FUNCTION(sqlrcur_closeresultset)3483 DLEXPORT ZEND_FUNCTION(sqlrcur_closeresultset) {
3484 ZVAL sqlrcur;
3485 if (ZEND_NUM_ARGS() != 1 ||
3486 GET_PARAMETERS(
3487 ZEND_NUM_ARGS() TSRMLS_CC,
3488 PARAMS("z")
3489 &sqlrcur) == FAILURE) {
3490 WRONG_PARAM_COUNT;
3491 }
3492 sqlrcursor *cursor=NULL;
3493 ZEND_FETCH_RESOURCE(cursor,
3494 sqlrcursor *,
3495 sqlrcur,
3496 -1,
3497 "sqlrelay cursor",
3498 sqlrelay_cursor);
3499 if (cursor) {
3500 cursor->closeResultSet();
3501 }
3502 }
3503
ZEND_FUNCTION(sqlrcon_ping)3504 DLEXPORT ZEND_FUNCTION(sqlrcon_ping) {
3505 ZVAL sqlrcon;
3506 bool r;
3507 if (ZEND_NUM_ARGS() != 1 ||
3508 GET_PARAMETERS(
3509 ZEND_NUM_ARGS() TSRMLS_CC,
3510 PARAMS("z")
3511 &sqlrcon) == FAILURE) {
3512 WRONG_PARAM_COUNT;
3513 }
3514 sqlrconnection *connection=NULL;
3515 ZEND_FETCH_RESOURCE(connection,
3516 sqlrconnection *,
3517 sqlrcon,
3518 -1,
3519 "sqlrelay connection",
3520 sqlrelay_connection);
3521 if (connection) {
3522 r=connection->ping();
3523 RETURN_LONG(r);
3524 }
3525 RETURN_LONG(0);
3526 }
3527
ZEND_FUNCTION(sqlrcon_selectdatabase)3528 DLEXPORT ZEND_FUNCTION(sqlrcon_selectdatabase) {
3529 ZVAL sqlrcon;
3530 ZVAL database;
3531 bool r;
3532 if (ZEND_NUM_ARGS() != 2 ||
3533 GET_PARAMETERS(
3534 ZEND_NUM_ARGS() TSRMLS_CC,
3535 PARAMS("zz")
3536 &sqlrcon,
3537 &database) == FAILURE) {
3538 WRONG_PARAM_COUNT;
3539 }
3540 convert_to_string_ex(database);
3541 sqlrconnection *connection=NULL;
3542 ZEND_FETCH_RESOURCE(connection,
3543 sqlrconnection *,
3544 sqlrcon,
3545 -1,
3546 "sqlrelay connection",
3547 sqlrelay_connection);
3548 if (connection) {
3549 r=connection->selectDatabase(SVAL(database));
3550 RETURN_LONG(r);
3551 }
3552 RETURN_LONG(0);
3553 }
3554
ZEND_FUNCTION(sqlrcon_getcurrentdatabase)3555 DLEXPORT ZEND_FUNCTION(sqlrcon_getcurrentdatabase) {
3556 ZVAL sqlrcon;
3557 const char *r;
3558 if (ZEND_NUM_ARGS() != 1 ||
3559 GET_PARAMETERS(
3560 ZEND_NUM_ARGS() TSRMLS_CC,
3561 PARAMS("z")
3562 &sqlrcon) == FAILURE) {
3563 WRONG_PARAM_COUNT;
3564 }
3565 sqlrconnection *connection=NULL;
3566 ZEND_FETCH_RESOURCE(connection,
3567 sqlrconnection *,
3568 sqlrcon,
3569 -1,
3570 "sqlrelay connection",
3571 sqlrelay_connection);
3572 if (connection) {
3573 r=connection->getCurrentDatabase();
3574 if (r) {
3575 RET_STRING(const_cast<char *>(r),1);
3576 }
3577 }
3578 RETURN_FALSE;
3579 }
3580
ZEND_FUNCTION(sqlrcon_getlastinsertid)3581 DLEXPORT ZEND_FUNCTION(sqlrcon_getlastinsertid) {
3582 ZVAL sqlrcon;
3583 if (ZEND_NUM_ARGS() != 1 ||
3584 GET_PARAMETERS(
3585 ZEND_NUM_ARGS() TSRMLS_CC,
3586 PARAMS("z")
3587 &sqlrcon) == FAILURE) {
3588 WRONG_PARAM_COUNT;
3589 }
3590 sqlrconnection *connection=NULL;
3591 ZEND_FETCH_RESOURCE(connection,
3592 sqlrconnection *,
3593 sqlrcon,
3594 -1,
3595 "sqlrelay connection",
3596 sqlrelay_connection);
3597 if (connection) {
3598 RETURN_LONG(connection->getLastInsertId());
3599 }
3600 RETURN_FALSE;
3601 }
3602
ZEND_FUNCTION(sqlrcon_autocommiton)3603 DLEXPORT ZEND_FUNCTION(sqlrcon_autocommiton) {
3604 ZVAL sqlrcon;
3605 bool r;
3606 if (ZEND_NUM_ARGS() != 1 ||
3607 GET_PARAMETERS(
3608 ZEND_NUM_ARGS() TSRMLS_CC,
3609 PARAMS("z")
3610 &sqlrcon) == FAILURE) {
3611 WRONG_PARAM_COUNT;
3612 }
3613 sqlrconnection *connection=NULL;
3614 ZEND_FETCH_RESOURCE(connection,
3615 sqlrconnection *,
3616 sqlrcon,
3617 -1,
3618 "sqlrelay connection",
3619 sqlrelay_connection);
3620 if (connection) {
3621 r=connection->autoCommitOn();
3622 RETURN_LONG(r);
3623 }
3624 RETURN_LONG(0);
3625 }
3626
ZEND_FUNCTION(sqlrcon_autocommitoff)3627 DLEXPORT ZEND_FUNCTION(sqlrcon_autocommitoff) {
3628 ZVAL sqlrcon;
3629 bool r;
3630 if (ZEND_NUM_ARGS() != 1 ||
3631 GET_PARAMETERS(
3632 ZEND_NUM_ARGS() TSRMLS_CC,
3633 PARAMS("z")
3634 &sqlrcon) == FAILURE) {
3635 WRONG_PARAM_COUNT;
3636 }
3637 sqlrconnection *connection=NULL;
3638 ZEND_FETCH_RESOURCE(connection,
3639 sqlrconnection *,
3640 sqlrcon,
3641 -1,
3642 "sqlrelay connection",
3643 sqlrelay_connection);
3644 if (connection) {
3645 r=connection->autoCommitOff();
3646 RETURN_LONG(r);
3647 }
3648 RETURN_LONG(0);
3649 }
3650
ZEND_FUNCTION(sqlrcon_begin)3651 DLEXPORT ZEND_FUNCTION(sqlrcon_begin) {
3652 ZVAL sqlrcon;
3653 bool r;
3654 if (ZEND_NUM_ARGS() != 1 ||
3655 GET_PARAMETERS(
3656 ZEND_NUM_ARGS() TSRMLS_CC,
3657 PARAMS("z")
3658 &sqlrcon) == FAILURE) {
3659 WRONG_PARAM_COUNT;
3660 }
3661 sqlrconnection *connection=NULL;
3662 ZEND_FETCH_RESOURCE(connection,
3663 sqlrconnection *,
3664 sqlrcon,
3665 -1,
3666 "sqlrelay connection",
3667 sqlrelay_connection);
3668 if (connection) {
3669 r=connection->begin();
3670 RETURN_LONG(r);
3671 }
3672 RETURN_LONG(0);
3673 }
3674
ZEND_FUNCTION(sqlrcon_commit)3675 DLEXPORT ZEND_FUNCTION(sqlrcon_commit) {
3676 ZVAL sqlrcon;
3677 bool r;
3678 if (ZEND_NUM_ARGS() != 1 ||
3679 GET_PARAMETERS(
3680 ZEND_NUM_ARGS() TSRMLS_CC,
3681 PARAMS("z")
3682 &sqlrcon) == FAILURE) {
3683 WRONG_PARAM_COUNT;
3684 }
3685 sqlrconnection *connection=NULL;
3686 ZEND_FETCH_RESOURCE(connection,
3687 sqlrconnection *,
3688 sqlrcon,
3689 -1,
3690 "sqlrelay connection",
3691 sqlrelay_connection);
3692 if (connection) {
3693 r=connection->commit();
3694 RETURN_LONG(r);
3695 }
3696 RETURN_LONG(0);
3697 }
3698
ZEND_FUNCTION(sqlrcon_rollback)3699 DLEXPORT ZEND_FUNCTION(sqlrcon_rollback) {
3700 ZVAL sqlrcon;
3701 bool r;
3702 if (ZEND_NUM_ARGS() != 1 ||
3703 GET_PARAMETERS(
3704 ZEND_NUM_ARGS() TSRMLS_CC,
3705 PARAMS("z")
3706 &sqlrcon) == FAILURE) {
3707 WRONG_PARAM_COUNT;
3708 }
3709 sqlrconnection *connection=NULL;
3710 ZEND_FETCH_RESOURCE(connection,
3711 sqlrconnection *,
3712 sqlrcon,
3713 -1,
3714 "sqlrelay connection",
3715 sqlrelay_connection);
3716 if (connection) {
3717 r=connection->rollback();
3718 RETURN_LONG(r);
3719 }
3720 RETURN_LONG(0);
3721 }
3722
ZEND_FUNCTION(sqlrcon_identify)3723 DLEXPORT ZEND_FUNCTION(sqlrcon_identify) {
3724 ZVAL sqlrcon;
3725 const char *r;
3726 if (ZEND_NUM_ARGS() != 1 ||
3727 GET_PARAMETERS(
3728 ZEND_NUM_ARGS() TSRMLS_CC,
3729 PARAMS("z")
3730 &sqlrcon) == FAILURE) {
3731 WRONG_PARAM_COUNT;
3732 }
3733 sqlrconnection *connection=NULL;
3734 ZEND_FETCH_RESOURCE(connection,
3735 sqlrconnection *,
3736 sqlrcon,
3737 -1,
3738 "sqlrelay connection",
3739 sqlrelay_connection);
3740 if (connection) {
3741 r=connection->identify();
3742 if (r) {
3743 RET_STRING(const_cast<char *>(r),1);
3744 }
3745 }
3746 RETURN_FALSE;
3747 }
3748
ZEND_FUNCTION(sqlrcon_bindformat)3749 DLEXPORT ZEND_FUNCTION(sqlrcon_bindformat) {
3750 ZVAL sqlrcon;
3751 const char *r;
3752 if (ZEND_NUM_ARGS() != 1 ||
3753 GET_PARAMETERS(
3754 ZEND_NUM_ARGS() TSRMLS_CC,
3755 PARAMS("z")
3756 &sqlrcon) == FAILURE) {
3757 WRONG_PARAM_COUNT;
3758 }
3759 sqlrconnection *connection=NULL;
3760 ZEND_FETCH_RESOURCE(connection,
3761 sqlrconnection *,
3762 sqlrcon,
3763 -1,
3764 "sqlrelay connection",
3765 sqlrelay_connection);
3766 if (connection) {
3767 r=connection->bindFormat();
3768 if (r) {
3769 RET_STRING(const_cast<char *>(r),1);
3770 }
3771 }
3772 RETURN_FALSE;
3773 }
3774
ZEND_FUNCTION(sqlrcon_dbversion)3775 DLEXPORT ZEND_FUNCTION(sqlrcon_dbversion) {
3776 ZVAL sqlrcon;
3777 const char *r;
3778 if (ZEND_NUM_ARGS() != 1 ||
3779 GET_PARAMETERS(
3780 ZEND_NUM_ARGS() TSRMLS_CC,
3781 PARAMS("z")
3782 &sqlrcon) == FAILURE) {
3783 WRONG_PARAM_COUNT;
3784 }
3785 sqlrconnection *connection=NULL;
3786 ZEND_FETCH_RESOURCE(connection,
3787 sqlrconnection *,
3788 sqlrcon,
3789 -1,
3790 "sqlrelay connection",
3791 sqlrelay_connection);
3792 if (connection) {
3793 r=connection->dbVersion();
3794 if (r) {
3795 RET_STRING(const_cast<char *>(r),1);
3796 }
3797 }
3798 RETURN_FALSE;
3799 }
3800
3801
ZEND_FUNCTION(sqlrcon_dbhostname)3802 DLEXPORT ZEND_FUNCTION(sqlrcon_dbhostname) {
3803 ZVAL sqlrcon;
3804 const char *r;
3805 if (ZEND_NUM_ARGS() != 1 ||
3806 GET_PARAMETERS(
3807 ZEND_NUM_ARGS() TSRMLS_CC,
3808 PARAMS("z")
3809 &sqlrcon) == FAILURE) {
3810 WRONG_PARAM_COUNT;
3811 }
3812 sqlrconnection *connection=NULL;
3813 ZEND_FETCH_RESOURCE(connection,
3814 sqlrconnection *,
3815 sqlrcon,
3816 -1,
3817 "sqlrelay connection",
3818 sqlrelay_connection);
3819 if (connection) {
3820 r=connection->dbHostName();
3821 if (r) {
3822 RET_STRING(const_cast<char *>(r),1);
3823 }
3824 }
3825 RETURN_FALSE;
3826 }
3827
3828
ZEND_FUNCTION(sqlrcon_dbipaddress)3829 DLEXPORT ZEND_FUNCTION(sqlrcon_dbipaddress) {
3830 ZVAL sqlrcon;
3831 const char *r;
3832 if (ZEND_NUM_ARGS() != 1 ||
3833 GET_PARAMETERS(
3834 ZEND_NUM_ARGS() TSRMLS_CC,
3835 PARAMS("z")
3836 &sqlrcon) == FAILURE) {
3837 WRONG_PARAM_COUNT;
3838 }
3839 sqlrconnection *connection=NULL;
3840 ZEND_FETCH_RESOURCE(connection,
3841 sqlrconnection *,
3842 sqlrcon,
3843 -1,
3844 "sqlrelay connection",
3845 sqlrelay_connection);
3846 if (connection) {
3847 r=connection->dbIpAddress();
3848 if (r) {
3849 RET_STRING(const_cast<char *>(r),1);
3850 }
3851 }
3852 RETURN_FALSE;
3853 }
3854
ZEND_FUNCTION(sqlrcon_serverversion)3855 DLEXPORT ZEND_FUNCTION(sqlrcon_serverversion) {
3856 ZVAL sqlrcon;
3857 const char *r;
3858 if (ZEND_NUM_ARGS() != 1 ||
3859 GET_PARAMETERS(
3860 ZEND_NUM_ARGS() TSRMLS_CC,
3861 PARAMS("z")
3862 &sqlrcon) == FAILURE) {
3863 WRONG_PARAM_COUNT;
3864 }
3865 sqlrconnection *connection=NULL;
3866 ZEND_FETCH_RESOURCE(connection,
3867 sqlrconnection *,
3868 sqlrcon,
3869 -1,
3870 "sqlrelay connection",
3871 sqlrelay_connection);
3872 if (connection) {
3873 r=connection->serverVersion();
3874 if (r) {
3875 RET_STRING(const_cast<char *>(r),1);
3876 }
3877 }
3878 RETURN_FALSE;
3879 }
3880
ZEND_FUNCTION(sqlrcon_clientversion)3881 DLEXPORT ZEND_FUNCTION(sqlrcon_clientversion) {
3882 ZVAL sqlrcon;
3883 const char *r;
3884 if (ZEND_NUM_ARGS() != 1 ||
3885 GET_PARAMETERS(
3886 ZEND_NUM_ARGS() TSRMLS_CC,
3887 PARAMS("z")
3888 &sqlrcon) == FAILURE) {
3889 WRONG_PARAM_COUNT;
3890 }
3891 sqlrconnection *connection=NULL;
3892 ZEND_FETCH_RESOURCE(connection,
3893 sqlrconnection *,
3894 sqlrcon,
3895 -1,
3896 "sqlrelay connection",
3897 sqlrelay_connection);
3898 if (connection) {
3899 r=connection->clientVersion();
3900 if (r) {
3901 RET_STRING(const_cast<char *>(r),1);
3902 }
3903 }
3904 RETURN_FALSE;
3905 }
3906
3907 zend_function_entry sql_relay_functions[] = {
3908 ZEND_FE(sqlrcon_alloc,NULL)
3909 ZEND_FE(sqlrcon_free,NULL)
3910 ZEND_FE(sqlrcon_setconnecttimeout,NULL)
3911 ZEND_FE(sqlrcon_setauthenticationtimeout,NULL)
3912 ZEND_FE(sqlrcon_setresponsetimeout,NULL)
3913 ZEND_FE(sqlrcon_setbindvariabledelimiters,NULL)
3914 ZEND_FE(sqlrcon_getbindvariabledelimiterquestionmarksupported,NULL)
3915 ZEND_FE(sqlrcon_getbindvariabledelimitercolonsupported,NULL)
3916 ZEND_FE(sqlrcon_getbindvariabledelimiteratsignsupported,NULL)
3917 ZEND_FE(sqlrcon_getbindvariabledelimiterdollarsignsupported,NULL)
3918 ZEND_FE(sqlrcon_enablekerberos,NULL)
3919 ZEND_FE(sqlrcon_enabletls,NULL)
3920 ZEND_FE(sqlrcon_disableencryption,NULL)
3921 ZEND_FE(sqlrcon_endsession,NULL)
3922 ZEND_FE(sqlrcon_suspendsession,NULL)
3923 ZEND_FE(sqlrcon_getconnectionport,NULL)
3924 ZEND_FE(sqlrcon_getconnectionsocket,NULL)
3925 ZEND_FE(sqlrcon_resumesession,NULL)
3926 ZEND_FE(sqlrcon_errormessage,NULL)
3927 ZEND_FE(sqlrcon_errornumber,NULL)
3928 ZEND_FE(sqlrcon_debugon,NULL)
3929 ZEND_FE(sqlrcon_debugoff,NULL)
3930 ZEND_FE(sqlrcon_getdebug,NULL)
3931 ZEND_FE(sqlrcon_setdebugfile,NULL)
3932 ZEND_FE(sqlrcon_setclientinfo,NULL)
3933 ZEND_FE(sqlrcon_getclientinfo,NULL)
3934 ZEND_FE(sqlrcur_alloc,NULL)
3935 ZEND_FE(sqlrcur_free,NULL)
3936 ZEND_FE(sqlrcur_setresultsetbuffersize,NULL)
3937 ZEND_FE(sqlrcur_getresultsetbuffersize,NULL)
3938 ZEND_FE(sqlrcur_dontgetcolumninfo,NULL)
3939 ZEND_FE(sqlrcur_getcolumninfo,NULL)
3940 ZEND_FE(sqlrcur_mixedcasecolumnnames,NULL)
3941 ZEND_FE(sqlrcur_uppercasecolumnnames,NULL)
3942 ZEND_FE(sqlrcur_lowercasecolumnnames,NULL)
3943 ZEND_FE(sqlrcur_cachetofile,NULL)
3944 ZEND_FE(sqlrcur_setcachettl,NULL)
3945 ZEND_FE(sqlrcur_getcachefilename,NULL)
3946 ZEND_FE(sqlrcur_cacheoff,NULL)
3947 ZEND_FE(sqlrcur_getdatabaselist,NULL)
3948 ZEND_FE(sqlrcur_gettablelist,NULL)
3949 ZEND_FE(sqlrcur_getcolumnlist,NULL)
3950 ZEND_FE(sqlrcur_sendquery,NULL)
3951 ZEND_FE(sqlrcur_sendquerywithlength,NULL)
3952 ZEND_FE(sqlrcur_sendfilequery,NULL)
3953 ZEND_FE(sqlrcur_preparequery,NULL)
3954 ZEND_FE(sqlrcur_preparequerywithlength,NULL)
3955 ZEND_FE(sqlrcur_preparefilequery,NULL)
3956 ZEND_FE(sqlrcur_substitution,NULL)
3957 ZEND_FE(sqlrcur_clearbinds,NULL)
3958 ZEND_FE(sqlrcur_countbindvariables,NULL)
3959 ZEND_FE(sqlrcur_inputbind,NULL)
3960 ZEND_FE(sqlrcur_inputbindblob,NULL)
3961 ZEND_FE(sqlrcur_inputbindclob,NULL)
3962 ZEND_FE(sqlrcur_defineoutputbindstring,NULL)
3963 ZEND_FE(sqlrcur_defineoutputbindinteger,NULL)
3964 ZEND_FE(sqlrcur_defineoutputbinddouble,NULL)
3965 ZEND_FE(sqlrcur_defineoutputbindblob,NULL)
3966 ZEND_FE(sqlrcur_defineoutputbindclob,NULL)
3967 ZEND_FE(sqlrcur_defineoutputbindcursor,NULL)
3968 ZEND_FE(sqlrcur_substitutions,NULL)
3969 ZEND_FE(sqlrcur_inputbinds,NULL)
3970 ZEND_FE(sqlrcur_validatebinds,NULL)
3971 ZEND_FE(sqlrcur_validbind,NULL)
3972 ZEND_FE(sqlrcur_executequery,NULL)
3973 ZEND_FE(sqlrcur_fetchfrombindcursor,NULL)
3974 ZEND_FE(sqlrcur_getoutputbindstring,NULL)
3975 ZEND_FE(sqlrcur_getoutputbindblob,NULL)
3976 ZEND_FE(sqlrcur_getoutputbindclob,NULL)
3977 ZEND_FE(sqlrcur_getoutputbindinteger,NULL)
3978 ZEND_FE(sqlrcur_getoutputbinddouble,NULL)
3979 ZEND_FE(sqlrcur_getoutputbindlength,NULL)
3980 ZEND_FE(sqlrcur_getoutputbindcursor,NULL)
3981 ZEND_FE(sqlrcur_opencachedresultset,NULL)
3982 ZEND_FE(sqlrcur_colcount,NULL)
3983 ZEND_FE(sqlrcur_rowcount,NULL)
3984 ZEND_FE(sqlrcur_totalrows,NULL)
3985 ZEND_FE(sqlrcur_affectedrows,NULL)
3986 ZEND_FE(sqlrcur_firstrowindex,NULL)
3987 ZEND_FE(sqlrcur_endofresultset,NULL)
3988 ZEND_FE(sqlrcur_errormessage,NULL)
3989 ZEND_FE(sqlrcur_errornumber,NULL)
3990 ZEND_FE(sqlrcur_getnullsasemptystrings,NULL)
3991 ZEND_FE(sqlrcur_getnullsasnulls,NULL)
3992 ZEND_FE(sqlrcur_getfield,NULL)
3993 ZEND_FE(sqlrcur_getfieldasinteger,NULL)
3994 ZEND_FE(sqlrcur_getfieldasdouble,NULL)
3995 ZEND_FE(sqlrcur_getfieldlength,NULL)
3996 ZEND_FE(sqlrcur_getrow,NULL)
3997 ZEND_FE(sqlrcur_getrowassoc,NULL)
3998 ZEND_FE(sqlrcur_getrowlengths,NULL)
3999 ZEND_FE(sqlrcur_getrowlengthsassoc,NULL)
4000 ZEND_FE(sqlrcur_getcolumnnames,NULL)
4001 ZEND_FE(sqlrcur_getcolumnname,NULL)
4002 ZEND_FE(sqlrcur_getcolumntype,NULL)
4003 ZEND_FE(sqlrcur_getcolumnlength,NULL)
4004 ZEND_FE(sqlrcur_getcolumnprecision,NULL)
4005 ZEND_FE(sqlrcur_getcolumnscale,NULL)
4006 ZEND_FE(sqlrcur_getcolumnisnullable,NULL)
4007 ZEND_FE(sqlrcur_getcolumnisprimarykey,NULL)
4008 ZEND_FE(sqlrcur_getcolumnisunique,NULL)
4009 ZEND_FE(sqlrcur_getcolumnispartofkey,NULL)
4010 ZEND_FE(sqlrcur_getcolumnisunsigned,NULL)
4011 ZEND_FE(sqlrcur_getcolumniszerofilled,NULL)
4012 ZEND_FE(sqlrcur_getcolumnisbinary,NULL)
4013 ZEND_FE(sqlrcur_getcolumnisautoincrement,NULL)
4014 ZEND_FE(sqlrcur_getlongest,NULL)
4015 ZEND_FE(sqlrcur_getresultsetid,NULL)
4016 ZEND_FE(sqlrcur_suspendresultset,NULL)
4017 ZEND_FE(sqlrcur_resumeresultset,NULL)
4018 ZEND_FE(sqlrcur_resumecachedresultset,NULL)
4019 ZEND_FE(sqlrcon_ping,NULL)
4020 ZEND_FE(sqlrcon_identify,NULL)
4021 ZEND_FE(sqlrcon_selectdatabase,NULL)
4022 ZEND_FE(sqlrcon_getcurrentdatabase,NULL)
4023 ZEND_FE(sqlrcon_getlastinsertid,NULL)
4024 ZEND_FE(sqlrcon_autocommiton,NULL)
4025 ZEND_FE(sqlrcon_autocommitoff,NULL)
4026 ZEND_FE(sqlrcon_begin,NULL)
4027 ZEND_FE(sqlrcon_commit,NULL)
4028 ZEND_FE(sqlrcon_rollback,NULL)
4029 ZEND_FE(sqlrcon_bindformat,NULL)
4030 ZEND_FE(sqlrcon_dbversion,NULL)
4031 ZEND_FE(sqlrcon_dbhostname,NULL)
4032 ZEND_FE(sqlrcon_dbipaddress,NULL)
4033 ZEND_FE(sqlrcon_serverversion,NULL)
4034 ZEND_FE(sqlrcon_clientversion,NULL)
4035 {NULL,NULL,NULL}
4036 };
4037
4038 zend_module_entry sql_relay_module_entry = {
4039 #if ZEND_MODULE_API_NO >= 20010901
4040 STANDARD_MODULE_HEADER,
4041 #endif
4042 "sql_relay",
4043 sql_relay_functions,
4044 // extension-wide startup function
4045 #ifdef ZEND_MODULE_STARTUP_N
4046 ZEND_MODULE_STARTUP_N(sqlrelay),
4047 #else
4048 NULL,
4049 #endif
4050 // extension-wide shutdown function
4051 NULL,
4052 // per-request startup function
4053 NULL,
4054 // per-request shutdown function
4055 NULL,
4056 NULL,
4057 #if ZEND_MODULE_API_NO >= 20010901
4058 SQLR_VERSION,
4059 #endif
4060 STANDARD_MODULE_PROPERTIES
4061 };
4062
4063 ZEND_GET_MODULE(sql_relay)
4064
4065 }
4066