Ejemplo n.º 1
0
ONPHP_METHOD(Joiner, toDialectString)
{
	zval
		*dialect,
		*from = ONPHP_READ_PROPERTY(getThis(), "from"),
		*table;
	zend_class_entry **cep;
	smart_str string = {0};
	unsigned int i = 0, count = zend_hash_num_elements(Z_ARRVAL_P(from));
	
	if (!count) {
		RETURN_NULL();
	} else {
		smart_str_appendl(&string, " FROM ", 6);
	}
	
	ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
	
	ONPHP_FIND_FOREIGN_CLASS("SelectQuery", cep);
	
	for (i = 0; i < count; ++i) {
		zval *out;
		
		ONPHP_ARRAY_GET(from, i, table);
		
		if (i == 0) {
			/* nop */
		} else {
			if (ONPHP_INSTANCEOF(from, FromTable)) {
				zval *name;
				
				ONPHP_CALL_METHOD_0(table, "gettable", &name);
				
				if (instanceof_function(Z_OBJCE_P(table), *cep TSRMLS_CC)) {
					smart_str_appendl(&string, ", ", 2);
				} else {
					smart_str_appendc(&string, ' ');
				}
				
				zval_ptr_dtor(&name);
			} else {
				smart_str_appendc(&string, ' ');
			}
		}
		
		ONPHP_CALL_METHOD_1(table, "todialectstring", &out, dialect);
		
		onphp_append_zval_to_smart_string(&string, out);
		
		zval_ptr_dtor(&out);
	}
	
	smart_str_0(&string);
	
	RETURN_STRINGL(string.c, string.len, 0);
}
Ejemplo n.º 2
0
/* {{{ proto int runHandler()
   */
PHP_METHOD(Handler, runHandler)
{
	zend_class_entry * _this_ce;
	zval * _this_zval = NULL;
	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, Handler_ce_ptr) == FAILURE) {
		return;
	}
	_this_ce = Z_OBJCE_P(_this_zval);
	RETURN_LONG( PROP_GET_LONG(x) );
}
Ejemplo n.º 3
0
ZEND_API ZEND_COLD void zend_throw_exception_internal(zval *exception) /* {{{ */
{
#ifdef HAVE_DTRACE
	if (DTRACE_EXCEPTION_THROWN_ENABLED()) {
		if (exception != NULL) {
			DTRACE_EXCEPTION_THROWN(ZSTR_VAL(Z_OBJ_P(exception)->ce->name));
		} else {
			DTRACE_EXCEPTION_THROWN(NULL);
		}
	}
#endif /* HAVE_DTRACE */

	if (exception != NULL) {
		zend_object *previous = EG(exception);
		zend_exception_set_previous(Z_OBJ_P(exception), EG(exception));
		EG(exception) = Z_OBJ_P(exception);
		if (previous) {
			return;
		}
	}
	if (!EG(current_execute_data)) {
		if (exception && (Z_OBJCE_P(exception) == zend_ce_parse_error || Z_OBJCE_P(exception) == zend_ce_compile_error)) {
			return;
		}
		if(EG(exception)) {
			zend_exception_error(EG(exception), E_ERROR);
		}
		zend_error_noreturn(E_CORE_ERROR, "Exception thrown without a stack frame");
	}

	if (zend_throw_exception_hook) {
		zend_throw_exception_hook(exception);
	}

	if (!EG(current_execute_data)->func ||
	    !ZEND_USER_CODE(EG(current_execute_data)->func->common.type) ||
	    EG(current_execute_data)->opline->opcode == ZEND_HANDLE_EXCEPTION) {
		/* no need to rethrow the exception */
		return;
	}
	EG(opline_before_exception) = EG(current_execute_data)->opline;
	EG(current_execute_data)->opline = EG(exception_op);
}
Ejemplo n.º 4
0
PHP_METHOD(Pinyin, __construct)
{
    IPYNotation *pynotation = IPYFactory::getPYInstance();
    zval        *self       = getThis();
    zval        *z_pinyin;
    MAKE_STD_ZVAL(z_pinyin);

    ZEND_REGISTER_RESOURCE(z_pinyin, pynotation, le_pinyin_notation_link);
    zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("_pynotation"), z_pinyin TSRMLS_CC);
}
Ejemplo n.º 5
0
PHP_METHOD(dataserv, settable) {

	zval * self = getThis();
	zval * z_table;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_table) == FAILURE) {
		WRONG_PARAM_COUNT;
	}
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("table"), z_table TSRMLS_CC);
}
Ejemplo n.º 6
0
/** {{{ public ZeRecorder::fetchAll()
 */
PHP_METHOD(ze_recorder, fetchAll) {
	zval *   self        = NULL;
	zval *   stmt        = NULL;
	long     style       = 0;
	zval *   style_z     = NULL;
	zval *   success     = NULL;
	zval *   row         = NULL;

	/* PDO::FETCH_ASSOC */
	style   =   2;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l"
							 , &style
							 ) == FAILURE) {
		WRONG_PARAM_COUNT;
	}
	/* call execute */
	/* call fetch */

	self = getThis();

	stmt = zend_read_property(ze_recorder_ce, self, ZEND_STRL(ZE_STMT), 0 TSRMLS_CC);

	do {
		if (!stmt || Z_TYPE_P(stmt) != IS_OBJECT) {
			ze_error(E_ERROR TSRMLS_CC, "recorder.fetch.stmt.not_object");
			break;
		}

		zend_call_method(&stmt, Z_OBJCE_P(stmt), NULL, ZEND_STRL("execute"), &success, 0, NULL, NULL TSRMLS_CC);

		if (!success || EG(exception)) {
			break;
		}

		convert_to_boolean(success);

		if (Z_BVAL_P(success) == 1) {
			ALLOC_INIT_ZVAL(style_z);
			ZVAL_LONG(style_z, style);
			zend_call_method(&stmt, NULL, NULL, ZEND_STRL("fetchAll"), &row, 1, style_z, NULL TSRMLS_CC);
			zval_dtor(style_z);
			FREE_ZVAL(style_z);
		}

		zval_dtor(success);
		FREE_ZVAL(success);
	} while (0);

	if (row) {
		RETURN_ZVAL(row, 1, 1);
	} else {
		RETURN_FALSE;
	}
}
Ejemplo n.º 7
0
/**
 * Increments an object property
 */
int zephir_property_incr_decr(zval *object, char *property_name, unsigned int property_length, unsigned int increment)
{
	zval tmp;
	zend_class_entry *ce;
	int separated = 0;

	ZVAL_UNDEF(&tmp);

	if (Z_TYPE_P(object) != IS_OBJECT) {
		php_error_docref(NULL, E_WARNING, "Attempt to assign property of non-object");
		return FAILURE;
	}

	ce = Z_OBJCE_P(object);
	if (ce->parent) {
		ce = zephir_lookup_class_ce(ce, property_name, property_length);
	}

	zephir_read_property(&tmp, object, property_name, property_length, 0);
	if (Z_TYPE(tmp) > IS_UNDEF) {

		Z_TRY_DELREF(tmp);

		/** Separation only when refcount > 1 */
		if (Z_REFCOUNTED(tmp)) {
			if (Z_REFCOUNT(tmp) > 1) {
				if (!Z_ISREF(tmp)) {
					zval new_zv;
					ZVAL_DUP(&new_zv, &tmp);
					ZVAL_COPY_VALUE(&tmp, &new_zv);
					Z_TRY_DELREF(new_zv);
					separated = 1;
				}
			}
		} else {
			zval new_zv;
			ZVAL_DUP(&new_zv, &tmp);
			ZVAL_COPY_VALUE(&tmp, &new_zv);
			Z_TRY_DELREF(new_zv);
			separated = 1;
		}

		if (increment) {
			zephir_increment(&tmp);
		} else {
			zephir_decrement(&tmp);
		}

		if (separated) {
			zephir_update_property_zval(object, property_name, property_length, &tmp);
		}
	}

	return SUCCESS;
}
Ejemplo n.º 8
0
/**
 * Call method on an object which requires parameters
 *
 */
int phalcon_call_method_params(zval *return_value, zval *object, char *method_name, int method_len, zend_uint param_count, zval *params[], int check, int noreturn TSRMLS_DC){

	zval *fn = NULL;
	int status = FAILURE;
	zend_class_entry *active_scope = NULL;

	if (check) {
		if (!zend_hash_exists(&Z_OBJCE_P(object)->function_table, method_name, method_len+1)) {
			return FAILURE;
		}
	}

	if (!noreturn) {
		ALLOC_INIT_ZVAL(return_value);
	}

	PHALCON_ALLOC_ZVAL(fn);
	ZVAL_STRINGL(fn, method_name, method_len, 1);

	if (Z_TYPE_P(object) == IS_OBJECT) {
		active_scope = EG(scope);
		phalcon_find_scope(Z_OBJCE_P(object), method_name, method_len TSRMLS_CC);
		status = call_user_function(&Z_OBJCE_P(object)->function_table, &object, fn, return_value, param_count, params TSRMLS_CC);
		if (status == FAILURE) {
			EG(scope) = active_scope;
			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined method %s() on class %s", Z_STRVAL_P(fn), Z_OBJCE_P(object)->name);
			return FAILURE;
		}
		EG(scope) = active_scope;
	} else {
		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to method %s() on a non object", Z_STRVAL_P(fn));
		return FAILURE;
	}

	zval_ptr_dtor(&fn);

	if (!noreturn) {
		zval_ptr_dtor(&return_value);
	}

	return status;
}
Ejemplo n.º 9
0
/**
 * Checks if property exists on object
 */
int zephir_isset_property(zval *object, const char *property_name, unsigned int property_length)
{
	if (Z_TYPE_P(object) == IS_OBJECT) {
		if (likely(zend_hash_str_exists(&Z_OBJCE_P(object)->properties_info, property_name, property_length))) {
			return 1;
		}
		return zend_hash_str_exists(Z_OBJ_HT_P(object)->get_properties(object), property_name, property_length);
	}

	return 0;
}
Ejemplo n.º 10
0
/* {{{ unset an object property */
void pthreads_unset_property(PTHREADS_UNSET_PROPERTY_PASSTHRU_D) {
	PTHREAD pthreads = PTHREADS_FETCH_FROM(object);
	if (pthreads_store_delete(pthreads->store, Z_STRVAL_P(member), Z_STRLEN_P(member) TSRMLS_CC)!=SUCCESS){
		zend_error_noreturn(
			E_WARNING, 
			"pthreads has experienced an internal error while deleting %s::$%s", 
			Z_OBJCE_P(object)->name, Z_STRVAL_P(member)
		);
	}
	zend_handlers->unset_property(PTHREADS_UNSET_PROPERTY_PASSTHRU_C);
} 
Ejemplo n.º 11
0
PHP_METHOD(Currency, __construct)
{
	char *currency_code;
	int currency_code_len;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &currency_code, &currency_code_len) == FAILURE) {
		return;
	}

	zend_update_property_stringl(Z_OBJCE_P(getThis()), getThis(), CURRENCY_PROP_CURRENCYCODE_WS, currency_code, currency_code_len);
}
Ejemplo n.º 12
0
PHP_METHOD(pdo_connect_pool_PDOStatement, current)
{
    zval *pos, *rs, *row = NULL;
    zend_class_entry *ce;
    ce = Z_OBJCE_P(getThis());
    pos = cp_zend_read_property(ce, getThis(), "pos", sizeof ("pos") - 1, 0 TSRMLS_DC);
    rs = cp_zend_read_property(ce, getThis(), "rs", sizeof ("rs") - 1, 0 TSRMLS_DC);

    cp_zend_hash_index_find(Z_ARRVAL_P(rs), Z_LVAL_P(pos), (void**) &row);
    RETVAL_ZVAL(row, 1, 1);
}
Ejemplo n.º 13
0
/* {{{ proto string confirm_searcher_compiled(string arg)
   Return a string to confirm that the module is compiled in */
PHP_METHOD(Searcher,__construct)
{
	char *rulefile = NULL,*imgfile = NULL;
	int rulefile_len,imgfile_len;
	zval *rulefile_zval,*imgfile_zval,*cvalue,*nnvalue, *self;
	void* c = NULL;
	int nn = 0;
	long ret = 0;
 
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "!zz", &rulefile_zval, &imgfile_zval) == FAILURE) {
		WRONG_PARAM_COUNT;
	}
 	
 	if(Z_TYPE_P(rulefile_zval) != IS_NULL){
 		c = parseRuleFile(Z_STRVAL_P(rulefile_zval),&nn);
 	}else{
 		if(Z_TYPE_P(imgfile_zval) != IS_NULL){
 			ret = releaseFromFile(Z_STRVAL_P(imgfile_zval),&c);
 		}else{
 			WRONG_PARAM_COUNT;
 		}
 	}

 	

	self = getThis();
 
	MAKE_STD_ZVAL(cvalue);
	ZVAL_LONG(cvalue, (int)c);

	SEPARATE_ZVAL_TO_MAKE_IS_REF(&cvalue);
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("_c"), cvalue TSRMLS_CC);

	MAKE_STD_ZVAL(nnvalue);
	ZVAL_LONG(nnvalue, nn);

	SEPARATE_ZVAL_TO_MAKE_IS_REF(&nnvalue);
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("_nn"), nnvalue TSRMLS_CC);
 
	RETURN_TRUE;
}
Ejemplo n.º 14
0
Archivo: db.cpp Proyecto: 191919/hhvm
PHP_METHOD(MongoDB, execute)
{
	zval *code = NULL, *args = NULL, *options = NULL, *zdata;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|aa", &code, &args, &options) == FAILURE) {
		return;
	}

	/* turn the first argument into MongoCode */
	if (Z_TYPE_P(code) != IS_OBJECT ||
		Z_OBJCE_P(code) != mongo_ce_Code) {
		if (Z_TYPE_P(code) == IS_STRING) {
			zval *obj;

			MAKE_STD_ZVAL(obj);
			object_init_ex(obj, mongo_ce_Code);
			MONGO_METHOD1(MongoCode, __construct, return_value, obj, code);
			code = obj;
		} else { /* This is broken code */
			php_error_docref(NULL TSRMLS_CC, E_ERROR, "The argument is neither an object of MongoCode or a string");
			return;
		}
	} else {
		zval_add_ref(&code);
	}

	if (!args) {
		MAKE_STD_ZVAL(args);
		array_init(args);
	} else {
		zval_add_ref(&args);
	}

	/* create { $eval : code, args : [] } */
	MAKE_STD_ZVAL(zdata);
	array_init(zdata);
	add_assoc_zval(zdata, "$eval", code);
	add_assoc_zval(zdata, "args", args);
	/* Check whether we have nolock as an option */
	if (options) {
		zval **nolock;

		if (zend_hash_find(HASH_P(options), "nolock", strlen("nolock") + 1, (void**) &nolock) == SUCCESS) {
			convert_to_boolean_ex(nolock);
			zval_add_ref(nolock);
			add_assoc_zval(zdata, "nolock", *nolock);
		}
	}

	MONGO_METHOD1(MongoDB, command, return_value, getThis(), zdata);

	zval_ptr_dtor(&zdata);
}
Ejemplo n.º 15
0
PHP_METHOD(pdo_connect_pool_PDOStatement, next)
{
    zval *pos, *next;
    CP_MAKE_STD_ZVAL(next);
    zend_class_entry *ce;
    ce = Z_OBJCE_P(getThis());
    pos = cp_zend_read_property(ce, getThis(), "pos", sizeof("pos") -1, 0 TSRMLS_DC);

    ZVAL_LONG(next, ++Z_LVAL_P(pos));
    zend_update_property(ce, getThis(),  "pos", sizeof("pos") -1, next TSRMLS_CC);

}
Ejemplo n.º 16
0
/* {{{ proto boolean XMLReader::open(string URI [, string encoding [, int options]])
Sets the URI that the XMLReader will parse. */
PHP_METHOD(xmlreader, open)
{
	zval *id;
	size_t source_len = 0, encoding_len = 0;
	zend_long options = 0;
	xmlreader_object *intern = NULL;
	char *source, *valid_file = NULL;
	char *encoding = NULL;
	char resolved_path[MAXPATHLEN + 1];
	xmlTextReaderPtr reader = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!l", &source, &source_len, &encoding, &encoding_len, &options) == FAILURE) {
		return;
	}

	id = getThis();
	if (id != NULL) {
		if (! instanceof_function(Z_OBJCE_P(id), xmlreader_class_entry)) {
			id = NULL;
		} else {
			intern = Z_XMLREADER_P(id);
			xmlreader_free_resources(intern);
		}
	}

	if (!source_len) {
		php_error_docref(NULL, E_WARNING, "Empty string supplied as input");
		RETURN_FALSE;
	}

	valid_file = _xmlreader_get_valid_file_path(source, resolved_path, MAXPATHLEN );

	if (valid_file) {
		reader = xmlReaderForFile(valid_file, encoding, options);
	}

	if (reader == NULL) {
		php_error_docref(NULL, E_WARNING, "Unable to open source data");
		RETURN_FALSE;
	}

	if (id == NULL) {
		object_init_ex(return_value, xmlreader_class_entry);
		intern = Z_XMLREADER_P(return_value);
		intern->ptr = reader;
		return;
	}

	intern->ptr = reader;

	RETURN_TRUE;

}
Ejemplo n.º 17
0
static int phalcon_translate_adapter_gettext_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC)
{
	char *msgstr;

	if (!is_phalcon_class(Z_OBJCE_P(object))) {
		return zend_get_std_object_handlers()->has_dimension(object, offset, check_empty TSRMLS_CC);
	}

	msgstr = gettext(Z_STRVAL_P(offset));

	return (1 == check_empty) ? strlen(msgstr) : 1;
}
Ejemplo n.º 18
0
PHP_METHOD(BatchStatement, add)
{
  zval *statement = NULL;
  zval *arguments = NULL;
  cassandra_batch_statement_entry *batch_statement_entry = NULL;
  cassandra_statement *self = NULL;

#if PHP_MAJOR_VERSION >= 7
  zval entry;
#endif

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &statement, &arguments) == FAILURE) {
    return;
  }

  if (!instanceof_function(Z_OBJCE_P(statement), cassandra_simple_statement_ce TSRMLS_CC) &&
      !instanceof_function(Z_OBJCE_P(statement), cassandra_prepared_statement_ce TSRMLS_CC)) {
    INVALID_ARGUMENT(statement, "an instance of Cassandra\\SimpleStatement or Cassandra\\PreparedStatement");
  }

  self = PHP_CASSANDRA_GET_STATEMENT(getThis());

  batch_statement_entry = (cassandra_batch_statement_entry *) ecalloc(1, sizeof(cassandra_batch_statement_entry));

  PHP5TO7_ZVAL_COPY(PHP5TO7_ZVAL_MAYBE_P(batch_statement_entry->statement), statement);

  if (arguments) {
    PHP5TO7_ZVAL_COPY(PHP5TO7_ZVAL_MAYBE_P(batch_statement_entry->arguments), arguments);
  }


#if PHP_MAJOR_VERSION >= 7
  ZVAL_PTR(&entry, batch_statement_entry);
  zend_hash_next_index_insert(&self->statements, &entry);
#else
  zend_hash_next_index_insert(&self->statements,
                              &batch_statement_entry, sizeof(cassandra_batch_statement_entry *),
                              NULL);
#endif
}
Ejemplo n.º 19
0
static zend_bool zend_valid_closure_binding(
		zend_closure *closure, zval *newthis, zend_class_entry *scope) /* {{{ */
{
	zend_function *func = &closure->func;
	zend_bool is_fake_closure = (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) != 0;
	if (newthis) {
		if (func->common.fn_flags & ZEND_ACC_STATIC) {
			zend_error(E_WARNING, "Cannot bind an instance to a static closure");
			return 0;
		}

		if (is_fake_closure && func->common.scope &&
				!instanceof_function(Z_OBJCE_P(newthis), func->common.scope)) {
			/* Binding incompatible $this to an internal method is not supported. */
			zend_error(E_WARNING, "Cannot bind method %s::%s() to object of class %s",
					ZSTR_VAL(func->common.scope->name),
					ZSTR_VAL(func->common.function_name),
					ZSTR_VAL(Z_OBJCE_P(newthis)->name));
			return 0;
		}
	} else if (!(func->common.fn_flags & ZEND_ACC_STATIC) && func->common.scope
			&& func->type == ZEND_INTERNAL_FUNCTION) {
		zend_error(E_WARNING, "Cannot unbind $this of internal method");
		return 0;
	}

	if (scope && scope != func->common.scope && scope->type == ZEND_INTERNAL_CLASS) {
		/* rebinding to internal class is not allowed */
		zend_error(E_WARNING, "Cannot bind closure to scope of internal class %s",
				ZSTR_VAL(scope->name));
		return 0;
	}

	if (is_fake_closure && scope != func->common.scope) {
		zend_error(E_WARNING, "Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure()");
		return 0;
	}

	return 1;
}
Ejemplo n.º 20
0
/**
 * Checks whether HTTP method is HEAD. if $_SERVER['REQUEST_METHOD']=='HEAD'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isHead){

	zval head = {}, method = {};

	if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) {
		RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "HEAD"));
	}

	PHALCON_STR(&head, ISV(HEAD));

	PHALCON_CALL_METHODW(&method, getThis(), "getmethod");
	is_equal_function(return_value, &method, &head);
}
Ejemplo n.º 21
0
PHP_METHOD(dataserv, loaddata) {
	zval * self = getThis();
	char * host, * user, * passwd, * db, * table;
	host = Z_STRVAL_P(zend_read_property(Z_OBJCE_P(self), self, ZEND_STRL("host"), 0 TSRMLS_CC));
	user = Z_STRVAL_P(zend_read_property(Z_OBJCE_P(self), self, ZEND_STRL("user"), 0 TSRMLS_CC));
	passwd = Z_STRVAL_P(zend_read_property(Z_OBJCE_P(self), self, ZEND_STRL("passwd"), 0 TSRMLS_CC));
	db = Z_STRVAL_P(zend_read_property(Z_OBJCE_P(self), self, ZEND_STRL("db"), 0 TSRMLS_CC));
	table = Z_STRVAL_P(zend_read_property(Z_OBJCE_P(self), self, ZEND_STRL("table"), 0 TSRMLS_CC));

	MYSQL mysql_conn; /* Connection handle */
	MYSQL_RES *mysql_result; /* Result handle */
	MYSQL_ROW mysql_row; /* Row data */
	char SQL[1024] = {0x00};

	if (mysql_init(&mysql_conn) == NULL)
	{
		php_printf("Initialization fails.\n");
		mysql_close(&mysql_conn);
		return;
	}

	if (mysql_real_connect(&mysql_conn, host, user, passwd, db, MYSQL_PORT, NULL, 128) == NULL)
	{
		php_printf("Connection fails.\n");
		mysql_close(&mysql_conn);
		return;
	}
	php_printf("load data into table '%s'.\n", table);
	sprintf(SQL,"LOAD DATA LOCAL INFILE '%s.sql' INTO TABLE %s.%s FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES STARTING BY '\\n'",table,db,table);
//	php_printf("%s\n", SQL);
	if (mysql_query(&mysql_conn, SQL) != 0)
	{
		php_printf("Query fails.\n");
		mysql_close(&mysql_conn);
		return;
	}
	mysql_free_result(mysql_result);
	mysql_close(&mysql_conn);
}
Ejemplo n.º 22
0
//call the service
PHP_METHOD(air_async_service, call) {
	AIR_INIT_THIS;

	zval *waiter = zend_read_property(air_async_service_ce, self, ZEND_STRL("_waiter"), 0 TSRMLS_CC);
	zval *self_id = zend_read_property(air_async_service_ce, self, ZEND_STRL("_id"), 0 TSRMLS_CC);
	zval *ret = NULL;
	zend_call_method_with_1_params(&waiter, Z_OBJCE_P(waiter), NULL, "response", &ret, self_id);
	if(ret){
		RETURN_ZVAL(ret, 1, 1);
	}else{
		RETURN_NULL();
	}
}
Ejemplo n.º 23
0
/**
 * Checks whether HTTP method is PATCH. if $_SERVER['REQUEST_METHOD']=='PATCH'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isPatch){

	zval patch = {}, method = {};

	if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) {
		RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "PATCH"));
	}

	PHALCON_STR(&patch, ISV(PATCH));

	PHALCON_CALL_METHODW(&method, getThis(), "getmethod");
	is_equal_function(return_value, &method, &patch);
}
Ejemplo n.º 24
0
Archivo: alinq.c Proyecto: wosiwo/clinq
ZEND_METHOD( alinq_class , ToArray )
{
    zval * dataSource;
    zval * reArrVal;
    zend_class_entry *ce;

    ce = Z_OBJCE_P(getThis());

    dataSource = zend_read_property(ce, getThis(), "dataSource", sizeof("dataSource")-1, 0 TSRMLS_DC);
    reArrVal = dataSource;
    zval_copy_ctor(reArrVal);
    RETURN_ZVAL(reArrVal,1,1);
}
Ejemplo n.º 25
0
/* {{{ proto void __construct([int _x = 345])
   */
PHP_METHOD(Handler, __construct)
{
	zend_class_entry * _this_ce;
	zval * _this_zval;
	long _x = 345;
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &_x) == FAILURE) {
		return;
	}
	_this_zval = getThis();
	_this_ce = Z_OBJCE_P(_this_zval);
  PROP_SET_LONG(x, _x);
	php_printf("Constructor: %d \n", PROP_GET_LONG(x) );
}
Ejemplo n.º 26
0
/**
 * Checks whether HTTP method is GET. if $_SERVER['REQUEST_METHOD']=='GET'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isGet){

	zval get = {}, method = {};

	if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) {
		RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "GET"));
	}

	PHALCON_STR(&get, ISV(GET));

	PHALCON_CALL_METHODW(&method, getThis(), "getmethod");
	is_equal_function(return_value, &method, &get);
}
Ejemplo n.º 27
0
/* {{{ */
int pthreads_has_property(PTHREADS_HAS_PROPERTY_PASSTHRU_D) {
	int isset = 0;
	zend_long *guard = NULL;
	pthreads_object_t* threaded = PTHREADS_FETCH_FROM(Z_OBJ_P(object));

	cache = NULL;

	if (Z_OBJCE_P(object)->__isset && (guard = pthreads_get_guard(&threaded->std, member)) && !((*guard) & IN_ISSET)) {
		zend_fcall_info fci = empty_fcall_info;
		zend_fcall_info_cache fcc = empty_fcall_info_cache;
		zval rv;

		ZVAL_UNDEF(&rv);

		fci.size = sizeof(zend_fcall_info);
		fci.retval = &rv;
		fci.object = &threaded->std;
		zend_fcall_info_argn(&fci, 1, member);
		fcc.initialized = 1;
		fcc.function_handler = Z_OBJCE_P(object)->__isset;
		fcc.object = &threaded->std;

		(*guard) |= IN_ISSET;
		zend_call_function(&fci, &fcc);
		(*guard) &= ~IN_ISSET;
	
		if (Z_TYPE(rv) != IS_UNDEF) {
			isset = 
				zend_is_true(&rv);
			zval_dtor(&rv);
		}
		zend_fcall_info_args_clear(&fci, 1);
	} else {
		isset = pthreads_store_isset(object, member, has_set_exists);
	}

	return isset;
}
Ejemplo n.º 28
0
Archivo: alinq.c Proyecto: wosiwo/clinq
ZEND_METHOD( alinq_class , __construct )
{
    zval * data_array; 
    zend_class_entry *ce;

    ce = Z_OBJCE_P(getThis());
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",&data_array) == FAILURE) {
        RETURN_NULL();
    }

    zend_update_property(alinq_class_ce, getThis(), "dataSource", sizeof("dataSource")-1, data_array TSRMLS_CC);

} 
PHP_METHOD(SolrCollapseFunction, __construct)
{
    long int index = SOLR_UNIQUE_FUNCTION_INDEX();
    uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE;
    solr_function_t *solr_function_dest = NULL;
    solr_function_t solr_function;
    zval *index_prop, *zvfield = NULL;

    solr_char_t *param_name = (solr_char_t *)"field";
    int param_name_len = sizeof("field");

    solr_string_t field_str;

    solr_char_t *field_name = NULL;
    int field_name_len = 0;

    memset(&solr_function, 0, sizeof(solr_function_t));

    if (zend_hash_index_update(SOLR_GLOBAL(functions),index,(void *) &solr_function, sizeof(solr_function_t), (void **) &solr_function_dest) == FAILURE)
    {
        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable");

        return ;
    }
    index_prop = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC);
    Z_LVAL_P(index_prop) = index;

    solr_function_dest->function_index = index;
    solr_function_dest->name = (solr_char_t *)"collapse";
    solr_function_dest->name_length = sizeof(solr_function_dest->name);

    /* Allocated memory for the params HashTable using fast cache for HashTables */
    ALLOC_HASHTABLE(solr_function_dest->params);
    zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_string_free_ex, SOLR_FUNCTIONS_PERSISTENT);

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE)
    {
        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters");
        return;
    }

    if (field_name_len > 0 ) {
        memset(&field_str, 0, sizeof(solr_string_t));
        solr_string_set(&field_str, (solr_char_t *)field_name, field_name_len);
        if(zend_hash_update(solr_function_dest->params, param_name, param_name_len, (void **)&field_str, sizeof(solr_string_t), NULL) == FAILURE)
        {
            php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field");
        }
    }
}
Ejemplo n.º 30
0
/** {{{ 从字符串载入js代码 */
PHP_METHOD(HyperMobile, loadjsfromstring) {
	char *arg;
	int arg_len;
	zval *value,*self;
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg,&arg_len) == FAILURE){
		WRONG_PARAM_COUNT;
	}
	self=getThis();
	MAKE_STD_ZVAL(value);
	ZVAL_STRING(value,arg,1);
	// SEPARATE_ZVAL_TO_MAKE_IS_REF(&value);
	zend_update_property(Z_OBJCE_P(self), self, ZEND_STRL("js_content"), value TSRMLS_CC);
	RETURN_TRUE;
}