Esempio n. 1
0
PHP_METHOD(Phalcon_Http_Uri, extend){

	zval *uri, *self, *parts = NULL, *parts2 = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &uri);

	PHALCON_CALL_SELF(&parts, "getParts");

	if (Z_TYPE_P(uri) != IS_OBJECT || Z_OBJCE_P(uri) != phalcon_http_uri_ce) {
		PHALCON_INIT_VAR(self);
		object_init_ex(self, phalcon_http_uri_ce);
		PHALCON_CALL_METHOD(NULL, self, "__construct", uri);

		PHALCON_CALL_METHOD(&parts2, self, "getParts");
	} else {
		PHALCON_CALL_METHOD(&parts2, self, "getParts");
	}

	phalcon_array_merge_recursive_n(parts, parts2);

	phalcon_update_property_this(getThis(), SL("_parts"), parts);

	RETURN_THIS();
}
Esempio n. 2
0
PHP_METHOD(Phalcon_Http_Client_Header, addMultiple){

	zval *values, *fields;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &values);

	fields = phalcon_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY TSRMLS_CC);

	phalcon_array_merge_recursive_n(&fields, values);

	phalcon_update_property_this(this_ptr, SL("_fields"), fields TSRMLS_CC);

	PHALCON_MM_RESTORE();
}
Esempio n. 3
0
PHP_METHOD(Phalcon_Http_Uri, extend)
{
	zval *uri, parts = {}, self = {}, parts2 = {};

	phalcon_fetch_params(0, 1, 0, &uri);

	PHALCON_CALL_SELFW(&parts, "getParts");

	if (Z_TYPE_P(uri) != IS_OBJECT || Z_OBJCE_P(uri) != phalcon_http_uri_ce) {
		object_init_ex(&self, phalcon_http_uri_ce);
		PHALCON_CALL_METHODW(NULL, &self, "__construct", uri);

		PHALCON_CALL_METHODW(&parts2, &self, "getParts");
	} else {
		PHALCON_CALL_METHODW(&parts2, &self, "getParts");
	}

	phalcon_array_merge_recursive_n(&parts, &parts2);

	phalcon_update_property_zval(getThis(), SL("_parts"), &parts);

	RETURN_THISW();
}
Esempio n. 4
0
/**
 * Gets the type of PHQL queries
 *
 *
 * @return int
 */
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder_Where, setConditions){

	zval *conditions, *bind_params = NULL, *bind_types = NULL, *type = NULL, merge = {}, merged_conditions = {}, merged_bind_params = {}, merged_bind_types;
	zval joind_condition = {}, *single_condition_array = NULL, current_conditions = {}, new_conditions = {};
	zend_string *str_key;
	ulong idx;

	phalcon_fetch_params(0, 1, 3, &conditions, &bind_params, &bind_types, &type);

	if (!bind_params) {
		bind_params = &PHALCON_GLOBAL(z_null);
	}

	if (!bind_types) {
		bind_types = &PHALCON_GLOBAL(z_null);
	}

	if (!type) {
		type = &PHALCON_GLOBAL(z_null);
	}

	ZVAL_BOOL(&merge, Z_TYPE_P(type) != IS_NULL ? 1 : 0);

	if (Z_TYPE_P(conditions) == IS_ARRAY) {
		/* ----------- INITIALIZING LOOP VARIABLES ----------- */

		/*
		 * array containing single condition for example:
		 * array(
		 *      array(
		 *           'status = :status:',
		 *           array('status' => 5),
		 *           array('status' => PDO::PARAM_INT),
		 *      ),
		 *      'name' => 'Dreamsxin',
		 * )
		 */
		array_init(&merged_conditions);
		array_init(&merged_bind_params);
		array_init(&merged_bind_types);

		ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(conditions), idx, str_key, single_condition_array) {
			zval single_condition_key = {}, condition_string = {}, tmp_bind_params = {}, tmp_bind_types = {};
			if (str_key) {
				ZVAL_STR(&single_condition_key, str_key);
			} else {
				ZVAL_LONG(&single_condition_key, idx);
			}
			if (Z_TYPE_P(single_condition_array) == IS_ARRAY
				&& phalcon_array_isset_fetch_long(&condition_string, single_condition_array, 0)
				&& phalcon_array_isset_fetch_long(&tmp_bind_params, single_condition_array, 1)
				&& Z_TYPE(condition_string) == IS_STRING
				&& Z_TYPE(tmp_bind_params) == IS_ARRAY
			) {	
				phalcon_array_update_zval(&merged_conditions, &condition_string, &condition_string, PH_COPY);
				phalcon_array_merge_recursive_n(&merged_bind_params, &tmp_bind_params);

				if (phalcon_array_isset_fetch_long(&tmp_bind_types, single_condition_array, 2) && Z_TYPE(tmp_bind_types) == IS_ARRAY) {
					phalcon_array_merge_recursive_n(&merged_bind_types, &tmp_bind_types);
				}
			} else if (Z_TYPE(single_condition_key) == IS_STRING) {
				PHALCON_CONCAT_VSVS(&condition_string, &single_condition_key, " = :", &single_condition_key, ":");

				phalcon_array_update_zval(&merged_conditions, &single_condition_key, &condition_string, PH_COPY);

				if (Z_TYPE_P(single_condition_array) == IS_ARRAY) {
					phalcon_array_merge_recursive_n(&merged_bind_params, single_condition_array);
				} else {
					phalcon_array_update_zval(&merged_bind_params, &single_condition_key, single_condition_array, PH_COPY);
				}
			}
		} ZEND_HASH_FOREACH_END();