STATUS => ZEND_RESULT_CODE
[m6w6/ext-pq] / src / php_pqstm.c
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: pq |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17 #include <php.h>
18 #include <ext/standard/php_smart_str.h>
19
20 #include "php_pq.h"
21 #include "php_pq_misc.h"
22 #include "php_pq_object.h"
23 #include "php_pqexc.h"
24 #include "php_pqconn.h"
25 #include "php_pqres.h"
26 #include "php_pqstm.h"
27
28 zend_class_entry *php_pqstm_class_entry;
29 static zend_object_handlers php_pqstm_object_handlers;
30 static HashTable php_pqstm_object_prophandlers;
31
32 static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_bool silent TSRMLS_DC)
33 {
34 if (obj->intern->allocated) {
35 char *quoted_name = PQescapeIdentifier(obj->intern->conn->intern->conn, obj->intern->name, strlen(obj->intern->name));
36
37 if (quoted_name) {
38 smart_str cmd = {0};
39
40 smart_str_appends(&cmd, "DEALLOCATE ");
41 smart_str_appends(&cmd, quoted_name);
42 smart_str_0(&cmd);
43
44 if (async) {
45 if (PQsendQuery(obj->intern->conn->intern->conn, cmd.c)) {
46 obj->intern->conn->intern->poller = PQconsumeInput;
47 php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
48 } else if (!silent) {
49 throw_exce(EX_IO TSRMLS_CC, "Failed to deallocate statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
50 }
51 } else {
52 PGresult *res;
53
54 if ((res = PQexec(obj->intern->conn->intern->conn, cmd.c))) {
55 PHP_PQclear(res);
56 } else if (!silent) {
57 throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to deallocate statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
58 }
59 }
60
61 PQfreemem(quoted_name);
62 smart_str_free(&cmd);
63 }
64
65 obj->intern->allocated = 0;
66 }
67 }
68
69 static void php_pqstm_object_free(void *o TSRMLS_DC)
70 {
71 php_pqstm_object_t *obj = o;
72 #if DBG_GC
73 fprintf(stderr, "FREE stm(#%d) %p (conn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->conn->zv.handle, obj->intern->conn);
74 #endif
75 if (obj->intern) {
76 if (obj->intern->conn->intern) {
77 php_pq_callback_dtor(&obj->intern->conn->intern->onevent);
78 php_pqstm_deallocate(obj, 0, 1 TSRMLS_CC);
79 php_pq_object_delref(obj->intern->conn TSRMLS_CC);
80 }
81 efree(obj->intern->name);
82 efree(obj->intern->query);
83 zend_hash_destroy(&obj->intern->bound);
84 if (obj->intern->params) {
85 php_pq_params_free(&obj->intern->params);
86 }
87 efree(obj->intern);
88 obj->intern = NULL;
89 }
90 zend_object_std_dtor((zend_object *) o TSRMLS_CC);
91 efree(obj);
92 }
93
94 zend_object_value php_pqstm_create_object_ex(zend_class_entry *ce, php_pqstm_t *intern, php_pqstm_object_t **ptr TSRMLS_DC)
95 {
96 php_pqstm_object_t *o;
97
98 o = ecalloc(1, sizeof(*o));
99 zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
100 object_properties_init((zend_object *) o, ce);
101 o->prophandler = &php_pqstm_object_prophandlers;
102
103 if (ptr) {
104 *ptr = o;
105 }
106
107 if (intern) {
108 o->intern = intern;
109 }
110
111 o->zv.handle = zend_objects_store_put((zend_object *) o, NULL, php_pqstm_object_free, NULL TSRMLS_CC);
112 o->zv.handlers = &php_pqstm_object_handlers;
113
114 return o->zv;
115 }
116
117 static zend_object_value php_pqstm_create_object(zend_class_entry *class_type TSRMLS_DC)
118 {
119 return php_pqstm_create_object_ex(class_type, NULL, NULL TSRMLS_CC);
120 }
121
122 static void php_pqstm_object_read_name(zval *object, void *o, zval *return_value TSRMLS_DC)
123 {
124 php_pqstm_object_t *obj = o;
125
126 RETVAL_STRING(obj->intern->name, 1);
127 }
128
129 static void php_pqstm_object_read_connection(zval *object, void *o, zval *return_value TSRMLS_DC)
130 {
131 php_pqstm_object_t *obj = o;
132
133 php_pq_object_to_zval(obj->intern->conn, &return_value TSRMLS_CC);
134 }
135
136 static void php_pqstm_object_read_query(zval *object, void *o, zval *return_value TSRMLS_DC)
137 {
138 php_pqstm_object_t *obj = o;
139
140 RETVAL_STRING(obj->intern->query, 1);
141 }
142
143 static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value TSRMLS_DC)
144 {
145 int i;
146 php_pqstm_object_t *obj = o;
147
148 array_init_size(return_value, obj->intern->params->type.count);
149 for (i = 0; i < obj->intern->params->type.count; i++) {
150 add_next_index_long(return_value, (long)obj->intern->params->type.oids[i]);
151 }
152 }
153
154 php_pqstm_t *php_pqstm_init(php_pqconn_object_t *conn, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC)
155 {
156 php_pqstm_t *stm = ecalloc(1, sizeof(*stm));
157
158 php_pq_object_addref(conn TSRMLS_CC);
159 stm->conn = conn;
160 stm->name = estrdup(name);
161 stm->params = params;
162 stm->query = estrdup(query);
163 stm->allocated = 1;
164
165 ZEND_INIT_SYMTABLE(&stm->bound);
166
167 return stm;
168 }
169
170 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_construct, 0, 0, 3)
171 ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)
172 ZEND_ARG_INFO(0, name)
173 ZEND_ARG_INFO(0, query)
174 ZEND_ARG_ARRAY_INFO(0, types, 1)
175 ZEND_ARG_INFO(0, async)
176 ZEND_END_ARG_INFO();
177 static PHP_METHOD(pqstm, __construct) {
178 zend_error_handling zeh;
179 zval *zconn, *ztypes = NULL;
180 char *name_str, *query_str;
181 int name_len, *query_len;
182 zend_bool async = 0;
183 ZEND_RESULT_CODE rv;
184
185 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
186 rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oss|a/!b", &zconn, php_pqconn_class_entry, &name_str, &name_len, &query_str, &query_len, &ztypes, &async);
187 zend_restore_error_handling(&zeh TSRMLS_CC);
188
189 if (SUCCESS == rv) {
190 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
191 php_pqconn_object_t *conn_obj = zend_object_store_get_object(zconn TSRMLS_CC);
192
193 if (obj->intern) {
194 throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\Statement already initialized");
195 } else if (!conn_obj->intern) {
196 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
197 } else {
198 php_pq_params_t *params = php_pq_params_init(&conn_obj->intern->converters, ztypes ? Z_ARRVAL_P(ztypes) : NULL, NULL TSRMLS_CC);
199
200 if (async) {
201 rv = php_pqconn_prepare_async(zconn, conn_obj, name_str, query_str, params TSRMLS_CC);
202 } else {
203 rv = php_pqconn_prepare(zconn, conn_obj, name_str, query_str, params TSRMLS_CC);
204 }
205
206 if (SUCCESS == rv) {
207 obj->intern = php_pqstm_init(conn_obj, name_str, query_str, params TSRMLS_CC);
208 }
209 }
210 }
211 }
212 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_bind, 0, 0, 2)
213 ZEND_ARG_INFO(0, param_no)
214 ZEND_ARG_INFO(1, param_ref)
215 ZEND_END_ARG_INFO();
216 static PHP_METHOD(pqstm, bind) {
217 long param_no;
218 zval **param_ref;
219 zend_error_handling zeh;
220 ZEND_RESULT_CODE rv;
221
222 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
223 rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lZ", &param_no, &param_ref);
224 zend_restore_error_handling(&zeh TSRMLS_CC);
225
226 if (SUCCESS == rv) {
227 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
228
229 if (!obj->intern) {
230 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
231 } else if (!obj->intern->allocated) {
232 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement has been deallocated");
233 } else {
234 SEPARATE_ZVAL_TO_MAKE_IS_REF(param_ref);
235 Z_ADDREF_PP(param_ref);
236 zend_hash_index_update(&obj->intern->bound, param_no, (void *) param_ref, sizeof(zval *), NULL);
237 zend_hash_sort(&obj->intern->bound, zend_qsort, php_pq_compare_index, 0 TSRMLS_CC);
238 }
239 }
240 }
241
242 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_exec, 0, 0, 0)
243 ZEND_ARG_ARRAY_INFO(0, params, 1)
244 ZEND_END_ARG_INFO();
245 static PHP_METHOD(pqstm, exec) {
246 zend_error_handling zeh;
247 zval *zparams = NULL;
248 ZEND_RESULT_CODE rv;
249
250 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
251 rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &zparams);
252 zend_restore_error_handling(&zeh TSRMLS_CC);
253
254 if (SUCCESS == rv) {
255 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
256
257 if (!obj->intern) {
258 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
259 } else if (!obj->intern->allocated) {
260 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement has been deallocated");
261 } else {
262 PGresult *res;
263
264 php_pq_params_set_params(obj->intern->params, zparams ? Z_ARRVAL_P(zparams) : &obj->intern->bound);
265 res = PQexecPrepared(obj->intern->conn->intern->conn, obj->intern->name, obj->intern->params->param.count, (const char *const*) obj->intern->params->param.strings, NULL, NULL, 0);
266 php_pq_params_set_params(obj->intern->params, NULL);
267
268 if (!res) {
269 throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to execute statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
270 } else if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
271 php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), &return_value TSRMLS_CC);
272 php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
273 }
274 }
275 }
276 }
277
278 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_exec_async, 0, 0, 0)
279 ZEND_ARG_ARRAY_INFO(0, params, 1)
280 ZEND_ARG_INFO(0, callable)
281 ZEND_END_ARG_INFO();
282 static PHP_METHOD(pqstm, execAsync) {
283 zend_error_handling zeh;
284 zval *zparams = NULL;
285 php_pq_callback_t resolver = {{0}};
286 ZEND_RESULT_CODE rv;
287
288 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
289 rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!f", &zparams, &resolver.fci, &resolver.fcc);
290 zend_restore_error_handling(&zeh TSRMLS_CC);
291
292 if (SUCCESS == rv) {
293 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
294
295 if (!obj->intern) {
296 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
297 } else if (!obj->intern->allocated) {
298 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement has been deallocated");
299 } else {
300 int rc;
301
302 php_pq_params_set_params(obj->intern->params, zparams ? Z_ARRVAL_P(zparams) : &obj->intern->bound);
303 rc = PQsendQueryPrepared(obj->intern->conn->intern->conn, obj->intern->name, obj->intern->params->param.count, (const char *const*) obj->intern->params->param.strings, NULL, NULL, 0);
304 php_pq_params_set_params(obj->intern->params, NULL);
305
306 if (!rc) {
307 throw_exce(EX_IO TSRMLS_CC, "Failed to execute statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
308 #if HAVE_PQSETSINGLEROWMODE
309 } else if (obj->intern->conn->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn->intern->conn)) {
310 throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
311 #endif
312 } else {
313 php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC);
314 obj->intern->conn->intern->poller = PQconsumeInput;
315 }
316
317 php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
318 }
319 }
320 }
321
322 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_desc, 0, 0, 0)
323 ZEND_END_ARG_INFO();
324 static PHP_METHOD(pqstm, desc) {
325 zend_error_handling zeh;
326 ZEND_RESULT_CODE rv;
327
328 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
329 rv = zend_parse_parameters_none();
330 zend_restore_error_handling(&zeh TSRMLS_CC);
331
332 if (SUCCESS == rv) {
333 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
334
335 if (!obj->intern) {
336 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
337 } else if (!obj->intern->allocated) {
338 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement has been deallocated");
339 } else {
340 PGresult *res = PQdescribePrepared(obj->intern->conn->intern->conn, obj->intern->name);
341
342 if (!res) {
343 throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to describe statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
344 } else {
345 if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
346 int p, params;
347
348 array_init(return_value);
349 for (p = 0, params = PQnparams(res); p < params; ++p) {
350 add_next_index_long(return_value, PQparamtype(res, p));
351 }
352 }
353 PHP_PQclear(res);
354 php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
355 }
356 }
357 }
358 }
359
360 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_desc_async, 0, 0, 1)
361 ZEND_ARG_INFO(0, callable)
362 ZEND_END_ARG_INFO();
363 static PHP_METHOD(pqstm, descAsync) {
364 zend_error_handling zeh;
365 php_pq_callback_t resolver = {{0}};
366 ZEND_RESULT_CODE rv;
367
368 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
369 rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &resolver.fci, &resolver.fcc);
370 zend_restore_error_handling(&zeh TSRMLS_CC);
371
372 if (SUCCESS == rv) {
373 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
374
375 if (!obj->intern) {
376 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
377 } else if (!obj->intern->allocated) {
378 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement has been deallocated");
379 } else if (!PQsendDescribePrepared(obj->intern->conn->intern->conn, obj->intern->name)) {
380 throw_exce(EX_IO TSRMLS_CC, "Failed to describe statement: %s", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
381 } else {
382 php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC);
383 obj->intern->conn->intern->poller = PQconsumeInput;
384 php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
385 }
386 }
387 }
388
389 static zend_always_inline void php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
390 {
391 zend_error_handling zeh;
392 ZEND_RESULT_CODE rv;
393
394 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
395 rv = zend_parse_parameters_none();
396 zend_restore_error_handling(&zeh TSRMLS_CC);
397
398 if (rv == SUCCESS) {
399 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
400
401 if (!obj->intern) {
402 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
403 } else {
404 php_pqstm_deallocate(obj, async, 0 TSRMLS_CC);
405 }
406 }
407 }
408
409 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_deallocate, 0, 0, 0)
410 ZEND_END_ARG_INFO();
411 static PHP_METHOD(pqstm, deallocate)
412 {
413 php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
414 }
415
416 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_deallocate_async, 0, 0, 0)
417 ZEND_END_ARG_INFO();
418 static PHP_METHOD(pqstm, deallocateAsync)
419 {
420 php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
421 }
422
423 static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
424 {
425 zend_error_handling zeh;
426 ZEND_RESULT_CODE rv;
427
428 zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
429 rv = zend_parse_parameters_none();
430 zend_restore_error_handling(&zeh TSRMLS_CC);
431
432 if (rv == SUCCESS) {
433 php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
434
435 if (!obj->intern) {
436 throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
437 } else if (!obj->intern->allocated) {
438 if (async) {
439 rv = php_pqconn_prepare_async(NULL, obj->intern->conn, obj->intern->name, obj->intern->query, obj->intern->params TSRMLS_CC);
440 } else {
441 rv = php_pqconn_prepare(NULL, obj->intern->conn, obj->intern->name, obj->intern->query, obj->intern->params TSRMLS_CC);
442 }
443
444 if (SUCCESS == rv) {
445 obj->intern->allocated = 1;
446 }
447 }
448 }
449 }
450
451 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_prepare, 0, 0, 0)
452 ZEND_END_ARG_INFO();
453 static PHP_METHOD(pqstm, prepare)
454 {
455 php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
456 }
457
458 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_prepare_async, 0, 0, 0)
459 ZEND_END_ARG_INFO();
460 static PHP_METHOD(pqstm, prepareAsync)
461 {
462 php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
463 }
464
465 static zend_function_entry php_pqstm_methods[] = {
466 PHP_ME(pqstm, __construct, ai_pqstm_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
467 PHP_ME(pqstm, bind, ai_pqstm_bind, ZEND_ACC_PUBLIC)
468 PHP_ME(pqstm, deallocate, ai_pqstm_deallocate, ZEND_ACC_PUBLIC)
469 PHP_ME(pqstm, deallocateAsync, ai_pqstm_deallocate_async, ZEND_ACC_PUBLIC)
470 PHP_ME(pqstm, desc, ai_pqstm_desc, ZEND_ACC_PUBLIC)
471 PHP_ME(pqstm, descAsync, ai_pqstm_desc_async, ZEND_ACC_PUBLIC)
472 PHP_ME(pqstm, exec, ai_pqstm_exec, ZEND_ACC_PUBLIC)
473 PHP_ME(pqstm, execAsync, ai_pqstm_exec_async, ZEND_ACC_PUBLIC)
474 PHP_ME(pqstm, prepare, ai_pqstm_prepare, ZEND_ACC_PUBLIC)
475 PHP_ME(pqstm, prepareAsync, ai_pqstm_prepare_async, ZEND_ACC_PUBLIC)
476 {0}
477 };
478
479 PHP_MSHUTDOWN_FUNCTION(pqstm)
480 {
481 zend_hash_destroy(&php_pqstm_object_prophandlers);
482 return SUCCESS;
483 }
484
485 PHP_MINIT_FUNCTION(pqstm)
486 {
487 zend_class_entry ce = {0};
488 php_pq_object_prophandler_t ph = {0};
489
490 INIT_NS_CLASS_ENTRY(ce, "pq", "Statement", php_pqstm_methods);
491 php_pqstm_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
492 php_pqstm_class_entry->create_object = php_pqstm_create_object;
493
494 memcpy(&php_pqstm_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
495 php_pqstm_object_handlers.read_property = php_pq_object_read_prop;
496 php_pqstm_object_handlers.write_property = php_pq_object_write_prop;
497 php_pqstm_object_handlers.clone_obj = NULL;
498 php_pqstm_object_handlers.get_property_ptr_ptr = NULL;
499 php_pqstm_object_handlers.get_gc = NULL;
500 php_pqstm_object_handlers.get_properties = php_pq_object_properties;
501 php_pqstm_object_handlers.get_debug_info = php_pq_object_debug_info;
502
503 zend_hash_init(&php_pqstm_object_prophandlers, 2, NULL, NULL, 1);
504
505 zend_declare_property_null(php_pqstm_class_entry, ZEND_STRL("name"), ZEND_ACC_PUBLIC TSRMLS_CC);
506 ph.read = php_pqstm_object_read_name;
507 zend_hash_add(&php_pqstm_object_prophandlers, "name", sizeof("name"), (void *) &ph, sizeof(ph), NULL);
508
509 zend_declare_property_null(php_pqstm_class_entry, ZEND_STRL("connection"), ZEND_ACC_PUBLIC TSRMLS_CC);
510 ph.read = php_pqstm_object_read_connection;
511 zend_hash_add(&php_pqstm_object_prophandlers, "connection", sizeof("connection"), (void *) &ph, sizeof(ph), NULL);
512
513 zend_declare_property_null(php_pqstm_class_entry, ZEND_STRL("query"), ZEND_ACC_PUBLIC TSRMLS_CC);
514 ph.read = php_pqstm_object_read_query;
515 zend_hash_add(&php_pqstm_object_prophandlers, "query", sizeof("query"), (void *) &ph, sizeof(ph), NULL);
516
517 zend_declare_property_null(php_pqstm_class_entry, ZEND_STRL("types"), ZEND_ACC_PUBLIC TSRMLS_CC);
518 ph.read = php_pqstm_object_read_types;
519 zend_hash_add(&php_pqstm_object_prophandlers, "types", sizeof("types"), (void *) &ph, sizeof(ph), NULL);
520
521 return SUCCESS;
522 }
523
524 /*
525 * Local variables:
526 * tab-width: 4
527 * c-basic-offset: 4
528 * End:
529 * vim600: noet sw=4 ts=4 fdm=marker
530 * vim<600: noet sw=4 ts=4
531 */