• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PHALCON_IS_TRUE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PHALCON_IS_TRUE函数的典型用法代码示例。如果您正苦于以下问题:C++ PHALCON_IS_TRUE函数的具体用法?C++ PHALCON_IS_TRUE怎么用?C++ PHALCON_IS_TRUE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PHALCON_IS_TRUE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PHP_METHOD

/**
 * Renders a view using the template engine
 *
 * @param string $path
 * @param array $params
 * @param boolean $mustClean
 */
PHP_METHOD(Phalcon_Mvc_View_Engine_Php, render){

	zval *path, *params, *must_clean = NULL, *value = NULL, *key = NULL, *contents;
	zval *view;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &path, &params, &must_clean) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (!must_clean) {
		PHALCON_INIT_VAR(must_clean);
		ZVAL_BOOL(must_clean, 0);
	}
	
	if (PHALCON_IS_TRUE(must_clean)) {
		PHALCON_CALL_FUNC_NORETURN("ob_clean");
	}
	if (Z_TYPE_P(params) == IS_ARRAY) { 
	
		if (!phalcon_is_iterable(params, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
			return;
		}
	
		while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
	
			PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
			PHALCON_GET_FOREACH_VALUE(value);
	
			if (phalcon_set_symbol(key, value TSRMLS_CC) == FAILURE){
				return;
			}
	
			zend_hash_move_forward_ex(ah0, &hp0);
		}
	
	}
	
	if (phalcon_require(path TSRMLS_CC) == FAILURE) {
		return;
	}
	if (PHALCON_IS_TRUE(must_clean)) {
		PHALCON_INIT_VAR(contents);
		PHALCON_CALL_FUNC(contents, "ob_get_contents");
	
		PHALCON_OBS_VAR(view);
		phalcon_read_property(&view, this_ptr, SL("_view"), PH_NOISY_CC);
		PHALCON_CALL_METHOD_PARAMS_1_NORETURN(view, "setcontent", contents);
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:BlueShark,项目名称:cphalcon,代码行数:63,代码来源:php.c


示例2: PHP_METHOD

/**
 * Executes the validation
 *
 * @param string $value
 * @param int $minimum
 * @param int $maximum
 * @return boolean
 */
PHP_METHOD(Phalcon_Validation_Validator_StringLength, valid){

	zval *value, *minimum = NULL, *maximum = NULL;
	zval *length = NULL, *valid = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &value, &minimum, &maximum);

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

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

	/* At least one of 'min' or 'max' must be set */
	if (Z_TYPE_P(minimum) == IS_NULL && Z_TYPE_P(maximum) == IS_NULL) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set");
		return;
	}

	/* Check if mbstring is available to calculate the correct length */
	if (phalcon_function_exists_ex(SL("mb_strlen")) == SUCCESS) {
		PHALCON_CALL_FUNCTION(&length, "mb_strlen", value);
	} else {
		convert_to_string(value);
		PHALCON_INIT_VAR(length);
		ZVAL_LONG(length, Z_STRLEN_P(value));
	}

	/* Maximum length */
	if (Z_TYPE_P(maximum) != IS_NULL) {
		PHALCON_INIT_NVAR(valid);
		is_smaller_function(valid, maximum, length);
		if (PHALCON_IS_TRUE(valid)) {
			phalcon_update_property_str(getThis(), SL("_type"), SL("TooLong"));
			RETURN_MM_FALSE;
		}
	}

	/* Minimum length */
	if (Z_TYPE_P(minimum) != IS_NULL) {
		PHALCON_INIT_NVAR(valid);
		is_smaller_function(valid, length, minimum);
		if (PHALCON_IS_TRUE(valid)) {
			phalcon_update_property_str(getThis(), SL("_type"), SL("TooShort"));
			RETURN_MM_FALSE;
		}
	}

	RETURN_MM_TRUE;
}
开发者ID:Myleft,项目名称:cphalcon7,代码行数:62,代码来源:stringlength.c


示例3: PHP_METHOD

/**
 * Stores cached content into the backend and stops the frontend
 *
 * @param string $keyName
 * @param string $content
 * @param long $lifetime
 * @param boolean $stopBuffer
 */
PHP_METHOD(Phalcon_Cache_Backend_Memory, save){

	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
	zval *cached_content = NULL, *prepared_content = NULL, *is_buffering = NULL;
	zval *last_key, *frontend;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer);
	
	if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {
		last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC);
	} else {
		zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC);
	
		PHALCON_INIT_VAR(last_key);
		PHALCON_CONCAT_VV(last_key, prefix, key_name);
	}

	if (!zend_is_true(last_key)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");
		return;
	}
	
	frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC);
	if (!content || Z_TYPE_P(content) == IS_NULL) {
		PHALCON_CALL_METHOD(&cached_content, frontend, "getcontent");
	} else {
		cached_content = content;
	}

	if (phalcon_is_numeric(cached_content))	{
		phalcon_update_property_array(this_ptr, SL("_data"), last_key, cached_content TSRMLS_CC);
	} else {
		PHALCON_CALL_METHOD(&prepared_content, frontend, "beforestore", cached_content);
		phalcon_update_property_array(this_ptr, SL("_data"), last_key, prepared_content TSRMLS_CC);
	}
	
	PHALCON_CALL_METHOD(&is_buffering, frontend, "isbuffering");

	if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) {
		PHALCON_CALL_METHOD(NULL, frontend, "stop");
	}
	
	if (PHALCON_IS_TRUE(is_buffering)) {
		zend_print_zval(cached_content, 0);
	}
	
	phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:100851766,项目名称:cphalcon,代码行数:60,代码来源:memory.c


示例4: PHP_METHOD

/**
 * Returns the messages stored in session
 *
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, _getSessionMessages){

	zval *remove, *dependency_injector, *service;
	zval *session, *index_name, *messages;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &remove);
	
	PHALCON_OBS_VAR(dependency_injector);
	phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	if (unlikely(Z_TYPE_P(dependency_injector) != IS_OBJECT)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service");
		return;
	}
	
	PHALCON_INIT_VAR(service);
	ZVAL_STRING(service, "session", 1);
	
	PHALCON_INIT_VAR(session);
	phalcon_call_method_p1(session, dependency_injector, "getshared", service);
	PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce);
	
	PHALCON_INIT_VAR(index_name);
	ZVAL_STRING(index_name, "_flashMessages", 1);
	
	PHALCON_INIT_VAR(messages);
	phalcon_call_method_p1(messages, session, "get", index_name);
	if (PHALCON_IS_TRUE(remove)) {
		phalcon_call_method_p1_noret(session, "remove", index_name);
	}
	
	RETURN_CCTOR(messages);
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:40,代码来源:session.c


示例5: PHP_METHOD

/**
 * Gets the current document title
 *
 * <code>
 * 	echo Phalcon\Tag::getTitle();
 * </code>
 *
 * <code>
 * 	{{ get_title() }}
 * </code>
 *
 * @return string
 */
PHP_METHOD(Phalcon_Tag, getTitle){

	zval *tags = NULL, *document_title, *eol, *title_html;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &tags);
	
	if (!tags) {
		PHALCON_INIT_VAR(tags);
		ZVAL_BOOL(tags, 1);
	}
	
	PHALCON_OBS_VAR(document_title);
	phalcon_read_static_property(&document_title, SL("phalcon\\tag"), SL("_documentTitle") TSRMLS_CC);
	if (PHALCON_IS_TRUE(tags)) {
		PHALCON_INIT_VAR(eol);
		ZVAL_STRING(eol, PHP_EOL, 1);
	
		PHALCON_INIT_VAR(title_html);
		PHALCON_CONCAT_SVSV(title_html, "<title>", document_title, "</title>", eol);
		RETURN_CTOR(title_html);
	}
	
	
	RETURN_CCTOR(document_title);
}
开发者ID:angkatan21,项目名称:cphalcon,代码行数:40,代码来源:tag.c


示例6: PHP_METHOD

/**
 * Phalcon\Mvc\Router constructor
 *
 * @param boolean $defaultRoutes
 */
PHP_METHOD(Phalcon_Mvc_Router, __construct) {

    zval *default_routes = NULL, *routes = NULL, *paths = NULL, *route = NULL;
    zval *a0 = NULL, *a1 = NULL;
    zval *c0 = NULL, *c1 = NULL;

    PHALCON_MM_GROW();

    PHALCON_ALLOC_ZVAL_MM(a0);
    array_init(a0);
    zend_update_property(phalcon_mvc_router_ce, this_ptr, SL("_params"), a0 TSRMLS_CC);

    PHALCON_ALLOC_ZVAL_MM(a1);
    array_init(a1);
    zend_update_property(phalcon_mvc_router_ce, this_ptr, SL("_defaultParams"), a1 TSRMLS_CC);

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &default_routes) == FAILURE) {
        PHALCON_MM_RESTORE();
        RETURN_NULL();
    }

    if (!default_routes) {
        PHALCON_ALLOC_ZVAL_MM(default_routes);
        ZVAL_BOOL(default_routes, 1);
    }

    PHALCON_INIT_VAR(routes);
    array_init(routes);
    if (PHALCON_IS_TRUE(default_routes)) {
        PHALCON_INIT_VAR(paths);
        array_init(paths);
        add_assoc_long_ex(paths, SL("controller")+1, 1);

        PHALCON_INIT_VAR(route);
        object_init_ex(route, phalcon_mvc_router_route_ce);

        PHALCON_INIT_VAR(c0);
        ZVAL_STRING(c0, "#^/([a-zA-Z0-9\\_]+)[/]{0,1}$#", 1);
        PHALCON_CALL_METHOD_PARAMS_2_NORETURN(route, "__construct", c0, paths, PH_CHECK);
        phalcon_array_append(&routes, route, PH_SEPARATE TSRMLS_CC);

        PHALCON_INIT_VAR(paths);
        array_init(paths);
        add_assoc_long_ex(paths, SL("controller")+1, 1);
        add_assoc_long_ex(paths, SL("action")+1, 2);
        add_assoc_long_ex(paths, SL("params")+1, 3);

        PHALCON_INIT_VAR(route);
        object_init_ex(route, phalcon_mvc_router_route_ce);

        PHALCON_INIT_VAR(c1);
        ZVAL_STRING(c1, "#^/([a-zA-Z0-9\\_]+)/([a-zA-Z0-9\\_]+)(/.*)*$#", 1);
        PHALCON_CALL_METHOD_PARAMS_2_NORETURN(route, "__construct", c1, paths, PH_CHECK);
        phalcon_array_append(&routes, route, PH_SEPARATE TSRMLS_CC);
    }

    phalcon_update_property_zval(this_ptr, SL("_routes"), routes TSRMLS_CC);

    PHALCON_MM_RESTORE();
}
开发者ID:peterericchen,项目名称:cphalcon,代码行数:65,代码来源:router.c


示例7: PHP_METHOD

/**
 * Returns the messages stored in session
 *
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, _getSessionMessages){

	zval *remove, *dependency_injector, *service;
	zval *session = NULL, *index_name;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &remove);
	
	dependency_injector = phalcon_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY TSRMLS_CC);
	if (unlikely(Z_TYPE_P(dependency_injector) != IS_OBJECT)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service");
		return;
	}
	
	PHALCON_INIT_VAR(service);
	PHALCON_ZVAL_MAYBE_INTERNED_STRING(service, phalcon_interned_session);
	
	PHALCON_CALL_METHOD(&session, dependency_injector, "getshared", service);
	PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce);
	
	PHALCON_INIT_VAR(index_name);
	ZVAL_STRING(index_name, "_flashMessages", 1);
	
	PHALCON_RETURN_CALL_METHOD(session, "get", index_name);
	if (PHALCON_IS_TRUE(remove)) {
		PHALCON_CALL_METHOD(NULL, session, "remove", index_name);
	}
	
	RETURN_MM();
}
开发者ID:banketree,项目名称:cphalcon,代码行数:37,代码来源:session.c


示例8: PHP_METHOD

/**
 * Returns the messages stored in session
 *
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, _getSessionMessages){

	zval *remove, *dependency_injector = NULL, *service;
	zval *session = NULL, *index_name;

	PHALCON_MM_GROW();

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

	PHALCON_CALL_METHOD(&dependency_injector, this_ptr, "getdi");
	
	PHALCON_INIT_VAR(service);
	PHALCON_ZVAL_MAYBE_INTERNED_STRING(service, phalcon_interned_session);
	
	PHALCON_CALL_METHOD(&session, dependency_injector, "getshared", service);
	PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce);
	
	PHALCON_INIT_VAR(index_name);
	ZVAL_STRING(index_name, "_flashMessages", 1);
	
	PHALCON_RETURN_CALL_METHOD(session, "get", index_name);
	if (PHALCON_IS_TRUE(remove)) {
		PHALCON_CALL_METHOD(NULL, session, "remove", index_name);
	}
	
	RETURN_MM();
}
开发者ID:Myleft,项目名称:cphalcon,代码行数:33,代码来源:session.c


示例9: PHP_METHOD

/**
 * Check if HTTP method match any of the passed methods
 *
 * @param string|array $methods
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isMethod) {

    zval *methods, *http_method, *is_equals = NULL, *method = NULL;
    HashTable *ah0;
    HashPosition hp0;
    zval **hd;

    PHALCON_MM_GROW();

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &methods) == FAILURE) {
        PHALCON_MM_RESTORE();
        RETURN_NULL();
    }

    PHALCON_INIT_VAR(http_method);
    PHALCON_CALL_METHOD(http_method, this_ptr, "getmethod", PH_NO_CHECK);
    if (Z_TYPE_P(methods) == IS_STRING) {
        PHALCON_INIT_VAR(is_equals);
        is_equal_function(is_equals, methods, http_method TSRMLS_CC);

        RETURN_NCTOR(is_equals);
    } else {

        if (!phalcon_valid_foreach(methods TSRMLS_CC)) {
            return;
        }

        ah0 = Z_ARRVAL_P(methods);
        zend_hash_internal_pointer_reset_ex(ah0, &hp0);

ph_cycle_start_0:

        if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {
            goto ph_cycle_end_0;
        }

        PHALCON_GET_FOREACH_VALUE(method);

        PHALCON_INIT_NVAR(is_equals);
        is_equal_function(is_equals, method, http_method TSRMLS_CC);
        if (PHALCON_IS_TRUE(is_equals)) {
            PHALCON_MM_RESTORE();
            RETURN_TRUE;
        }

        zend_hash_move_forward_ex(ah0, &hp0);
        goto ph_cycle_start_0;

ph_cycle_end_0:
        if(0) {}

    }

    PHALCON_MM_RESTORE();
    RETURN_FALSE;
}
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:62,代码来源:request.c


示例10: PHP_METHOD

/**
 * Gets row in a specific position of the resultset
 *
 * @param int $index
 * @return Phalcon\Mvc\ModelInterface
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet){

	zval *index, *count, *exists, *pointer, *current = NULL, *valid;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &index);
	
	PHALCON_INIT_VAR(count);
	phalcon_call_method(count, this_ptr, "count");
	
	PHALCON_INIT_VAR(exists);
	is_smaller_function(exists, index, count TSRMLS_CC);
	if (PHALCON_IS_TRUE(exists)) {
	
		/** 
		 * Check if the last record returned is the current requested
		 */
		PHALCON_OBS_VAR(pointer);
		phalcon_read_property_this(&pointer, this_ptr, SL("_pointer"), PH_NOISY_CC);
		if (PHALCON_IS_EQUAL(pointer, index)) {
			PHALCON_INIT_VAR(current);
			phalcon_call_method(current, this_ptr, "current");
			RETURN_CCTOR(current);
		}
	
		/** 
		 * Move the cursor to the specific position
		 */
		phalcon_call_method_p1_noret(this_ptr, "seek", index);
	
		/** 
		 * Check if the last record returned is the requested
		 */
		PHALCON_INIT_VAR(valid);
		phalcon_call_method(valid, this_ptr, "valid");
		if (PHALCON_IS_NOT_FALSE(valid)) {
			PHALCON_INIT_NVAR(current);
			phalcon_call_method(current, this_ptr, "current");
			RETURN_CCTOR(current);
		}
	
		RETURN_MM_FALSE;
	}
	
	PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor");
	return;
}
开发者ID:RSivakov,项目名称:cphalcon,代码行数:54,代码来源:resultset.c


示例11: PHP_METHOD

/**
 * Phalcon\Mvc\Model\Resultset\Simple constructor
 *
 * @param Phalcon\Mvc\Model $model
 * @param Phalcon\Db\Result\Pdo $result
 * @param Phalcon\Cache\Backend $cache
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct){

	zval *model = NULL, *result = NULL, *cache = NULL, *fetch_assoc = NULL, *limit = NULL;
	zval *row_count = NULL, *big_resultset = NULL;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &model, &result, &cache) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (!cache) {
		PHALCON_ALLOC_ZVAL_MM(cache);
		ZVAL_NULL(cache);
	}
	
	phalcon_update_property_zval(this_ptr, SL("_model"), model TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_result"), result TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_cache"), cache TSRMLS_CC);
	if (PHALCON_IS_NOT_FALSE(result)) {
		PHALCON_INIT_VAR(fetch_assoc);
		ZVAL_LONG(fetch_assoc, 1);
		PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", fetch_assoc, PH_NO_CHECK);
		
		PHALCON_INIT_VAR(limit);
		ZVAL_LONG(limit, 32);
		
		PHALCON_INIT_VAR(row_count);
		PHALCON_CALL_METHOD(row_count, result, "numrows", PH_NO_CHECK);
		
		PHALCON_INIT_VAR(big_resultset);
		is_smaller_function(big_resultset, limit, row_count TSRMLS_CC);
		if (PHALCON_IS_TRUE(big_resultset)) {
			phalcon_update_property_long(this_ptr, SL("_type"), 1 TSRMLS_CC);
		} else {
			phalcon_update_property_long(this_ptr, SL("_type"), 0 TSRMLS_CC);
		}
		
		phalcon_update_property_zval(this_ptr, SL("_count"), row_count TSRMLS_CC);
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:awakmu,项目名称:cphalcon,代码行数:51,代码来源:simple.c


示例12: PHP_METHOD

/**
 * Unregister the autoload method
 *
 * @return Phalcon\Loader
 */
PHP_METHOD(Phalcon_Loader, unregister){

	zval *registered, *autoloader;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(registered);
	phalcon_read_property(&registered, this_ptr, SL("_registered"), PH_NOISY_CC);
	if (PHALCON_IS_TRUE(registered)) {
		PHALCON_INIT_VAR(autoloader);
		array_init_size(autoloader, 2);
		phalcon_array_append(&autoloader, this_ptr, PH_SEPARATE TSRMLS_CC);
		add_next_index_stringl(autoloader, SL("autoLoad"), 1);
		PHALCON_CALL_FUNC_PARAMS_1_NORETURN("spl_autoload_unregister", autoloader);
	}
	
	
	RETURN_THIS();
}
开发者ID:BlueShark,项目名称:cphalcon,代码行数:24,代码来源:loader.c


示例13: PHP_METHOD

/**
 * Stops the frontend without store any cached content
 *
 * @param boolean $stopBuffer
 */
PHP_METHOD(Phalcon_Cache_Backend, stop){

	zval *stop_buffer = NULL, *frontend;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &stop_buffer);
	
	if (!stop_buffer) {
		PHALCON_INIT_VAR(stop_buffer);
		ZVAL_BOOL(stop_buffer, 1);
	}
	
	if (PHALCON_IS_TRUE(stop_buffer)) {
		PHALCON_OBS_VAR(frontend);
		phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
		PHALCON_CALL_METHOD_NORETURN(frontend, "stop");
	}
	phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:101010111100,项目名称:cphalcon,代码行数:27,代码来源:backend.c


示例14: PHP_METHOD

/**
 * Returns the messages stored in session
 *
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, _getSessionMessages){

	zval *remove, *dependency_injector, *service;
	zval *session, *index_name, *messages;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &remove) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	PHALCON_INIT_VAR(dependency_injector);
	phalcon_read_property(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service");
		return;
	}
	
	PHALCON_INIT_VAR(service);
	ZVAL_STRING(service, "session", 1);
	
	PHALCON_INIT_VAR(session);
	PHALCON_CALL_METHOD_PARAMS_1(session, dependency_injector, "getshared", service, PH_NO_CHECK);
	
	PHALCON_INIT_VAR(index_name);
	ZVAL_STRING(index_name, "_flashMessages", 1);
	
	PHALCON_INIT_VAR(messages);
	PHALCON_CALL_METHOD_PARAMS_1(messages, session, "get", index_name, PH_NO_CHECK);
	if (PHALCON_IS_TRUE(remove)) {
		PHALCON_CALL_METHOD_PARAMS_1_NORETURN(session, "remove", index_name, PH_NO_CHECK);
	}
	
	
	RETURN_CCTOR(messages);
}
开发者ID:alantonilopez,项目名称:cphalcon,代码行数:43,代码来源:session.c


示例15: PHP_METHOD

/**
 * Generates the SQL for LIMIT clause
 *
 *<code>
 * $sql = $dialect->limit('SELECT * FROM robots', 10);
 * echo $sql; // SELECT * FROM robots LIMIT 10
 *</code>
 *
 * @param string $sqlQuery
 * @param int $number
 * @return string
 */
PHP_METHOD(Phalcon_Db_Dialect, limit){

	zval *sql_query, *number, *is_numeric, *limit, *sql_limit;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql_query, &number) == FAILURE) {
		RETURN_MM_NULL();
	}

	PHALCON_INIT_VAR(is_numeric);
	PHALCON_CALL_FUNC_PARAMS_1(is_numeric, "is_numeric", number);
	if (PHALCON_IS_TRUE(is_numeric)) {
		PHALCON_INIT_VAR(limit);
		PHALCON_CALL_FUNC_PARAMS_1(limit, "intval", number);
	
		PHALCON_INIT_VAR(sql_limit);
		PHALCON_CONCAT_VSV(sql_limit, sql_query, " LIMIT ", limit);
		RETURN_CTOR(sql_limit);
	}
	
	
	RETURN_CCTOR(sql_query);
}
开发者ID:Gildus,项目名称:cphalcon,代码行数:36,代码来源:dialect.c


示例16: PHP_METHOD

/**
 * Stores cached content into the file backend and stops the frontend
 *
 * @param int|string $keyName
 * @param string $content
 * @param long $lifetime
 * @param boolean $stopBuffer
 */
PHP_METHOD(Phalcon_Cache_Backend_File, save){

	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
	zval *last_key = NULL, *prefix, *filtered, *frontend, *options;
	zval *cache_dir, *cache_file, *cached_content = NULL;
	zval *prepared_content, *is_buffering;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzzz", &key_name, &content, &lifetime, &stop_buffer) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (!key_name) {
		PHALCON_INIT_NVAR(key_name);
	}
	
	if (!content) {
		PHALCON_INIT_NVAR(content);
	}
	
	if (!lifetime) {
		PHALCON_INIT_NVAR(lifetime);
	}
	
	if (!stop_buffer) {
		PHALCON_INIT_NVAR(stop_buffer);
		ZVAL_BOOL(stop_buffer, 1);
	}
	
	if (Z_TYPE_P(key_name) == IS_NULL) {
		PHALCON_INIT_VAR(last_key);
		phalcon_read_property(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC);
	} else {
		PHALCON_INIT_VAR(prefix);
		phalcon_read_property(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC);
	
		PHALCON_INIT_VAR(filtered);
		phalcon_filter_alphanum(filtered, key_name);
	
		PHALCON_INIT_NVAR(last_key);
		PHALCON_CONCAT_VV(last_key, prefix, filtered);
	}
	if (!zend_is_true(last_key)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");
		return;
	}
	
	PHALCON_INIT_VAR(frontend);
	phalcon_read_property(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(options);
	phalcon_read_property(&options, this_ptr, SL("_options"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(cache_dir);
	phalcon_array_fetch_string(&cache_dir, options, SL("cacheDir"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(cache_file);
	PHALCON_CONCAT_VV(cache_file, cache_dir, last_key);
	if (!zend_is_true(content)) {
		PHALCON_INIT_VAR(cached_content);
		PHALCON_CALL_METHOD(cached_content, frontend, "getcontent", PH_NO_CHECK);
	} else {
		PHALCON_CPY_WRT(cached_content, content);
	}
	
	/** 
	 * We use file_put_contents to repect open-base-dir directive
	 */
	PHALCON_INIT_VAR(prepared_content);
	PHALCON_CALL_METHOD_PARAMS_1(prepared_content, frontend, "beforestore", cached_content, PH_NO_CHECK);
	PHALCON_CALL_FUNC_PARAMS_2_NORETURN("file_put_contents", cache_file, prepared_content);
	
	PHALCON_INIT_VAR(is_buffering);
	PHALCON_CALL_METHOD(is_buffering, frontend, "isbuffering", PH_NO_CHECK);
	if (PHALCON_IS_TRUE(stop_buffer)) {
		PHALCON_CALL_METHOD_NORETURN(frontend, "stop", PH_NO_CHECK);
	}
	
	if (PHALCON_IS_TRUE(is_buffering)) {
		zend_print_zval(cached_content, 0);
	}
	
	phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:96,代码来源:file.c


示例17: PHP_METHOD

/**
 * Outputs a message formatting it with HTML
 *
 *<code>
 * $flash->outputMessage('error', $message);
 *</code>
 *
 * @param string $type
 * @param string $message
 */
PHP_METHOD(Phalcon_Flash, outputMessage){

	zval *type, *message, *automatic_html, *classes;
	zval *type_classes, *joined_classes, *css_classes = NULL;
	zval *eol = NULL, *implicit_flush, *content, *msg = NULL, *html_message = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &type, &message) == FAILURE) {
		RETURN_MM_NULL();
	}

	PHALCON_OBS_VAR(automatic_html);
	phalcon_read_property(&automatic_html, this_ptr, SL("_automaticHtml"), PH_NOISY_CC);
	if (PHALCON_IS_TRUE(automatic_html)) {
	
		PHALCON_OBS_VAR(classes);
		phalcon_read_property(&classes, this_ptr, SL("_cssClasses"), PH_NOISY_CC);
		if (phalcon_array_isset(classes, type)) {
	
			PHALCON_OBS_VAR(type_classes);
			phalcon_array_fetch(&type_classes, classes, type, PH_NOISY_CC);
			if (Z_TYPE_P(type_classes) == IS_ARRAY) { 
				PHALCON_INIT_VAR(joined_classes);
				phalcon_fast_join_str(joined_classes, SL(" "), type_classes TSRMLS_CC);
	
				PHALCON_INIT_VAR(css_classes);
				PHALCON_CONCAT_SVS(css_classes, " class=\"", joined_classes, "\"");
			} else {
				PHALCON_INIT_NVAR(css_classes);
				PHALCON_CONCAT_SVS(css_classes, " class=\"", type_classes, "\"");
			}
		} else {
			PHALCON_INIT_NVAR(css_classes);
			ZVAL_STRING(css_classes, "", 1);
		}
	
		PHALCON_INIT_VAR(eol);
	
		PHALCON_INIT_NVAR(eol);
		ZVAL_STRING(eol, PHP_EOL, 1);
	}
	
	PHALCON_OBS_VAR(implicit_flush);
	phalcon_read_property(&implicit_flush, this_ptr, SL("_implicitFlush"), PH_NOISY_CC);
	if (Z_TYPE_P(message) == IS_ARRAY) { 
	
		/** 
		 * We create the message with implicit flush or other
		 */
		if (PHALCON_IS_FALSE(implicit_flush)) {
			PHALCON_INIT_VAR(content);
			ZVAL_STRING(content, "", 1);
		}
	
		/** 
		 * We create the message with implicit flush or other
		 */
	
		if (!phalcon_is_iterable(message, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
			return;
		}
	
		while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
	
			PHALCON_GET_FOREACH_VALUE(msg);
	
			/** 
			 * We create the applying formatting or not
			 */
			if (PHALCON_IS_TRUE(automatic_html)) {
				PHALCON_INIT_NVAR(html_message);
				PHALCON_CONCAT_SVSVSV(html_message, "<div", css_classes, ">", msg, "</div>", eol);
			} else {
				PHALCON_CPY_WRT(html_message, msg);
			}
			if (PHALCON_IS_TRUE(implicit_flush)) {
				zend_print_zval(html_message, 0);
			} else {
				phalcon_concat_self(&content, html_message TSRMLS_CC);
			}
	
			zend_hash_move_forward_ex(ah0, &hp0);
		}
	
		/** 
		 * We return the message as string if the implicit_flush is turned off
//.........这里部分代码省略.........
开发者ID:bicouy0,项目名称:cphalcon,代码行数:101,代码来源:flash.c


示例18: PHP_METHOD

/**
 * Outputs a message formatting it with HTML
 *
 * @param string $type
 * @param string $message
 */
PHP_METHOD(Phalcon_Flash, outputMessage){

	zval *type = NULL, *message = NULL, *automatic_html = NULL, *classes = NULL;
	zval *type_classes = NULL, *space = NULL, *joined_classes = NULL;
	zval *css_classes = NULL, *eol = NULL, *implicit_flush = NULL, *content = NULL;
	zval *msg = NULL, *html_message = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;
	int eval_int;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &type, &message) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	PHALCON_INIT_VAR(automatic_html);
	phalcon_read_property(&automatic_html, this_ptr, SL("_automaticHtml"), PH_NOISY_CC);
	if (PHALCON_IS_TRUE(automatic_html)) {
		PHALCON_INIT_VAR(classes);
		phalcon_read_property(&classes, this_ptr, SL("_cssClasses"), PH_NOISY_CC);
		eval_int = phalcon_array_isset(classes, type);
		if (eval_int) {
			PHALCON_INIT_VAR(type_classes);
			phalcon_array_fetch(&type_classes, classes, type, PH_NOISY_CC);
			if (Z_TYPE_P(type_classes) == IS_ARRAY) { 
				PHALCON_INIT_VAR(space);
				ZVAL_STRING(space, " ", 1);
				
				PHALCON_INIT_VAR(joined_classes);
				phalcon_fast_join(joined_classes, space, type_classes TSRMLS_CC);
				
				PHALCON_INIT_VAR(css_classes);
				PHALCON_CONCAT_SVS(css_classes, " class=\"", joined_classes, "\"");
			} else {
				PHALCON_INIT_VAR(css_classes);
				PHALCON_CONCAT_SVS(css_classes, " class=\"", type_classes, "\"");
			}
		} else {
			PHALCON_INIT_VAR(css_classes);
			ZVAL_STRING(css_classes, "", 1);
		}
		
		PHALCON_INIT_VAR(eol);
		zend_get_constant(SL("PHP_EOL"), eol TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(implicit_flush);
	phalcon_read_property(&implicit_flush, this_ptr, SL("_implicitFlush"), PH_NOISY_CC);
	if (Z_TYPE_P(message) == IS_ARRAY) { 
		if (PHALCON_IS_FALSE(implicit_flush)) {
			PHALCON_INIT_VAR(content);
			ZVAL_STRING(content, "", 1);
		}
		if (!phalcon_valid_foreach(message TSRMLS_CC)) {
			return;
		}
		
		ah0 = Z_ARRVAL_P(message);
		zend_hash_internal_pointer_reset_ex(ah0, &hp0);
		fes_3b3c_0:
			if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
				goto fee_3b3c_0;
			}
			
			PHALCON_INIT_VAR(msg);
			ZVAL_ZVAL(msg, *hd, 1, 0);
			if (PHALCON_IS_TRUE(automatic_html)) {
				PHALCON_INIT_VAR(html_message);
				PHALCON_CONCAT_SVSVSV(html_message, "<div", css_classes, ">", msg, "</div>", eol);
			} else {
				PHALCON_CPY_WRT(html_message, msg);
			}
			if (PHALCON_IS_TRUE(implicit_flush)) {
				zend_print_zval(html_message, 1);
			} else {
				phalcon_concat_self(&content, html_message TSRMLS_CC);
			}
			zend_hash_move_forward_ex(ah0, &hp0);
			goto fes_3b3c_0;
		fee_3b3c_0:
		
		if (PHALCON_IS_FALSE(implicit_flush)) {
			
			RETURN_CTOR(content);
		}
	} else {
		if (PHALCON_IS_TRUE(automatic_html)) {
			PHALCON_INIT_VAR(html_message);
			PHALCON_CONCAT_SVSVSV(html_message, "<div", css_classes, ">", message, "</div>", eol);
		} else {
			PHALCON_CPY_WRT(html_message, message);
//.........这里部分代码省略.........
开发者ID:croustibat,项目名称:cphalcon,代码行数:101,代码来源:flash.c


示例19: PHP_METHOD

/**
 * Setup a relation 1-n between two models
 *
 * @param 	Phalcon\Mvc\Model $model
 * @param mixed $fields
 * @param string $referenceModel
 * @param mixed $referencedFields
 * @param array $options
 */
PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany){

	zval *model, *fields, *reference_model, *referenced_fields;
	zval *options = NULL, *entity_name, *has_many, *number_fields;
	zval *number_referenced, *diferent_fields;
	zval *relation;
	zval *a0 = NULL;
	zval *r0 = NULL;
	zval *t0 = NULL;
	int eval_int;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzz|z", &model, &fields, &reference_model, &referenced_fields, &options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (!options) {
		PHALCON_INIT_NVAR(options);
		array_init(options);
	}
	
	PHALCON_INIT_VAR(entity_name);
	phalcon_get_class(entity_name, model TSRMLS_CC);
	
	PHALCON_INIT_VAR(has_many);
	phalcon_read_property(&has_many, this_ptr, SL("_hasMany"), PH_NOISY_CC);
	eval_int = phalcon_array_isset(has_many, entity_name);
	if (!eval_int) {
		PHALCON_INIT_VAR(a0);
		array_init(a0);
		phalcon_array_update_zval(&has_many, entity_name, &a0, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(r0);
	phalcon_array_fetch(&r0, has_many, entity_name, PH_NOISY_CC);
	eval_int = phalcon_array_isset(r0, reference_model);
	if (!eval_int) {
		if (Z_TYPE_P(referenced_fields) == IS_ARRAY) { 
			PHALCON_INIT_VAR(number_fields);
			phalcon_fast_count(number_fields, fields TSRMLS_CC);
			
			PHALCON_INIT_VAR(number_referenced);
			phalcon_fast_count(number_referenced, referenced_fields TSRMLS_CC);
			
			PHALCON_INIT_VAR(diferent_fields);
			is_not_equal_function(diferent_fields, number_fields, number_referenced TSRMLS_CC);
			if (PHALCON_IS_TRUE(diferent_fields)) {
				PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same");
				return;
			}
		}
		
		PHALCON_INIT_VAR(relation);
		array_init(relation);
		phalcon_array_update_string(&relation, SL("fi"), &fields, PH_COPY | PH_SEPARATE TSRMLS_CC);
		phalcon_array_update_string(&relation, SL("rt"), &reference_model, PH_COPY | PH_SEPARATE TSRMLS_CC);
		phalcon_array_update_string(&relation, SL("rf"), &referenced_fields, PH_COPY | PH_SEPARATE TSRMLS_CC);
		phalcon_array_update_string(&relation, SL("op"), &options, PH_COPY | PH_SEPARATE TSRMLS_CC);
		
		PHALCON_INIT_VAR(t0);
		phalcon_read_property(&t0, this_ptr, SL("_hasMany"), PH_NOISY_CC);
		phalcon_array_update_multi_2(&t0, entity_name, reference_model, &relation, 0 TSRMLS_CC);
		phalcon_update_property_zval(this_ptr, SL("_hasMany"), t0 TSRMLS_CC);
		PHALCON_MM_RESTORE();
		RETURN_TRUE;
	}
	
	PHALCON_MM_RESTORE();
	RETURN_FALSE;
}
开发者ID:alantonilopez,项目名称:cphalcon,代码行数:81,代码来源:manager.c


示例20: PHP_METHOD

/**
 * Stores cached content into the APC backend and stops the frontend
 *
 * @param string $keyName
 * @param string $content
 * @param long $lifetime
 * @param boolean $stopBuffer
 */
PHP_METHOD(Phalcon_Cache_Backend_Apc, save)
{
	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL, prefix = {}, frontend = {};
	zval last_key = {}, cached_content = {}, prepared_content = {}, last_lifetime = {}, ttl, is_buffering = {};

	phalcon_fetch_params(0, 0, 4, &key_name, &content, &lifetime, &stop_buffer);

	if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {
		phalcon_return_property(&last_key, getThis(), SL("_lastKey"));
	} else {
		phalcon_read_property(&prefix, getThis(), SL("_prefix"), PH_NOISY);

		PHALCON_CONCAT_SVV(&last_key, "_PHCA", &prefix, key_name);
	}

	if (!zend_is_true(&last_key)) {
		PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "The cache must be started first");
		return;
	}

	phalcon_read_property(&frontend, getThis(), SL("_frontend"), PH_NOISY);
	if (!content || Z_TYPE_P(content) == IS_NULL) {
		PHALCON_CALL_METHODW(&cached_content, &frontend, "getcontent");
	} else {
		PHALCON_CPY_WRT(&cached_content, content);
	}

	if (!phalcon_is_numeric(&cached_content)) {
		PHALCON_CALL_METHODW(&prepared_content, &frontend, "beforestore", &cached_content);
	} else {
		PHALCON_CPY_WRT(&prepared_content, &cached_content);
	}

	/** 
	 * Take the lifetime from the frontend or read it from the set in start()
	 */
	if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) {
		phalcon_read_property(&last_lifetime, getThis(), SL("_lastLifetime"), PH_NOISY);

		if (Z_TYPE(last_lifetime) == IS_NULL) {
			PHALCON_CALL_METHODW(&ttl, &frontend, "getlifetime");
		} else {
			PHALCON_CPY_WRT(&ttl, &last_lifetime);
		}
	} else {
		PHALCON_CPY_WRT(&ttl, lifetime);
	}

	/** 
	 * Call apc_store in the PHP userland since most of the time it isn't available at
	 * compile time
	 */
	PHALCON_CALL_FUNCTIONW(NULL, "apc_store", &last_key, &prepared_content, &ttl);

	PHALCON_CALL_METHODW(&is_buffering, &frontend, "isbuffering");
	if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) {
		PHALCON_CALL_METHODW(NULL, &frontend, "stop");
	}

	if (PHALCON_IS_TRUE(&is_buffering)) {
		zend_print_zval(&cached_content, 0);
	}

	phalcon_update_property_bool(getThis(), SL("_started"), 0);
}
开发者ID:dreamsxin,项目名称:cphalcon7,代码行数:73,代码来源:apc.c



注:本文中的PHALCON_IS_TRUE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PHALCON_MM_GROW函数代码示例发布时间:2022-05-30
下一篇:
C++ PHALCON_IS_FALSE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap