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