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"
20
zend_class_entry *php_driver_simple_statement_ce = NULL;
22
PHP_METHOD(SimpleStatement, __construct)
25
php_driver_statement *self = NULL;
27
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &cql) == FAILURE) {
31
if (Z_TYPE_P(cql) != IS_STRING) {
32
INVALID_ARGUMENT(cql, "a string");
35
self = PHP_DRIVER_GET_STATEMENT(getThis());
37
self->data.simple.cql = estrndup(Z_STRVAL_P(cql), Z_STRLEN_P(cql));
40
ZEND_BEGIN_ARG_INFO_EX(arginfo__construct, 0, ZEND_RETURN_VALUE, 1)
44
static zend_function_entry php_driver_simple_statement_methods[] = {
45
PHP_ME(SimpleStatement, __construct, arginfo__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
49
static zend_object_handlers php_driver_simple_statement_handlers;
52
php_driver_simple_statement_properties(zval *object TSRMLS_DC)
54
HashTable *props = zend_std_get_properties(object TSRMLS_CC);
60
php_driver_simple_statement_compare(zval *obj1, zval *obj2 TSRMLS_DC)
62
if (Z_OBJCE_P(obj1) != Z_OBJCE_P(obj2))
63
return 1; /* different classes */
65
return Z_OBJ_HANDLE_P(obj1) != Z_OBJ_HANDLE_P(obj1);
69
php_driver_simple_statement_free(php5to7_zend_object_free *object TSRMLS_DC)
71
php_driver_statement *self = PHP5TO7_ZEND_OBJECT_GET(statement, object);
73
if (self->data.simple.cql) {
74
efree(self->data.simple.cql);
75
self->data.simple.cql = NULL;
78
zend_object_std_dtor(&self->zval TSRMLS_CC);
79
PHP5TO7_MAYBE_EFREE(self);
82
static php5to7_zend_object
83
php_driver_simple_statement_new(zend_class_entry *ce TSRMLS_DC)
85
php_driver_statement *self =
86
PHP5TO7_ZEND_OBJECT_ECALLOC(statement, ce);
88
self->type = PHP_DRIVER_SIMPLE_STATEMENT;
89
self->data.simple.cql = NULL;
91
PHP5TO7_ZEND_OBJECT_INIT_EX(statement, simple_statement, self, ce);
94
void php_driver_define_SimpleStatement(TSRMLS_D)
98
INIT_CLASS_ENTRY(ce, PHP_DRIVER_NAMESPACE "\\SimpleStatement", php_driver_simple_statement_methods);
99
php_driver_simple_statement_ce = zend_register_internal_class(&ce TSRMLS_CC);
100
zend_class_implements(php_driver_simple_statement_ce TSRMLS_CC, 1, php_driver_statement_ce);
101
php_driver_simple_statement_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
102
php_driver_simple_statement_ce->create_object = php_driver_simple_statement_new;
104
memcpy(&php_driver_simple_statement_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
105
php_driver_simple_statement_handlers.get_properties = php_driver_simple_statement_properties;
106
php_driver_simple_statement_handlers.compare_objects = php_driver_simple_statement_compare;
107
php_driver_simple_statement_handlers.clone_obj = NULL;