2
* Copyright 2015-2016 DataStax, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include "php_driver.h"
18
#include "php_driver_types.h"
19
#include "util/future.h"
21
zend_class_entry *php_driver_future_prepared_statement_ce = NULL;
23
PHP_METHOD(FuturePreparedStatement, get)
26
php_driver_statement *prepared_statement = NULL;
28
php_driver_future_prepared_statement *self = PHP_DRIVER_GET_FUTURE_PREPARED_STATEMENT(getThis());
30
if (!PHP5TO7_ZVAL_IS_UNDEF(self->prepared_statement)) {
31
RETURN_ZVAL(PHP5TO7_ZVAL_MAYBE_P(self->prepared_statement), 1, 0);
34
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &timeout) == FAILURE) {
38
if (php_driver_future_wait_timed(self->future, timeout TSRMLS_CC) == FAILURE) {
42
if (php_driver_future_is_error(self->future TSRMLS_CC) == FAILURE) {
46
object_init_ex(return_value, php_driver_statement_ce);
47
PHP5TO7_ZVAL_COPY(PHP5TO7_ZVAL_MAYBE_P(self->prepared_statement), return_value);
49
prepared_statement = PHP_DRIVER_GET_STATEMENT(return_value);
51
prepared_statement->data.prepared.prepared = cass_future_get_prepared(self->future);
54
ZEND_BEGIN_ARG_INFO_EX(arginfo_timeout, 0, ZEND_RETURN_VALUE, 0)
55
ZEND_ARG_INFO(0, timeout)
58
static zend_function_entry php_driver_future_prepared_statement_methods[] = {
59
PHP_ME(FuturePreparedStatement, get, arginfo_timeout, ZEND_ACC_PUBLIC)
63
static zend_object_handlers php_driver_future_prepared_statement_handlers;
66
php_driver_future_prepared_statement_properties(zval *object TSRMLS_DC)
68
HashTable *props = zend_std_get_properties(object TSRMLS_CC);
74
php_driver_future_prepared_statement_compare(zval *obj1, zval *obj2 TSRMLS_DC)
76
if (Z_OBJCE_P(obj1) != Z_OBJCE_P(obj2))
77
return 1; /* different classes */
79
return Z_OBJ_HANDLE_P(obj1) != Z_OBJ_HANDLE_P(obj1);
83
php_driver_future_prepared_statement_free(php5to7_zend_object_free *object TSRMLS_DC)
85
php_driver_future_prepared_statement *self =
86
PHP5TO7_ZEND_OBJECT_GET(future_prepared_statement, object);
89
cass_future_free(self->future);
93
PHP5TO7_ZVAL_MAYBE_DESTROY(self->prepared_statement);
95
zend_object_std_dtor(&self->zval TSRMLS_CC);
96
PHP5TO7_MAYBE_EFREE(self);
99
static php5to7_zend_object
100
php_driver_future_prepared_statement_new(zend_class_entry *ce TSRMLS_DC)
102
php_driver_future_prepared_statement *self =
103
PHP5TO7_ZEND_OBJECT_ECALLOC(future_prepared_statement, ce);
106
PHP5TO7_ZVAL_UNDEF(self->prepared_statement);
108
PHP5TO7_ZEND_OBJECT_INIT(future_prepared_statement, self, ce);
111
void php_driver_define_FuturePreparedStatement(TSRMLS_D)
115
INIT_CLASS_ENTRY(ce, PHP_DRIVER_NAMESPACE "\\FuturePreparedStatement", php_driver_future_prepared_statement_methods);
116
php_driver_future_prepared_statement_ce = zend_register_internal_class(&ce TSRMLS_CC);
117
zend_class_implements(php_driver_future_prepared_statement_ce TSRMLS_CC, 1, php_driver_future_ce);
118
php_driver_future_prepared_statement_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
119
php_driver_future_prepared_statement_ce->create_object = php_driver_future_prepared_statement_new;
121
memcpy(&php_driver_future_prepared_statement_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
122
php_driver_future_prepared_statement_handlers.get_properties = php_driver_future_prepared_statement_properties;
123
php_driver_future_prepared_statement_handlers.compare_objects = php_driver_future_prepared_statement_compare;
124
php_driver_future_prepared_statement_handlers.clone_obj = NULL;