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

C++ phalcon_array_fetch_string函数代码示例

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

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



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

示例1: PHP_METHOD

/**
 * Handles routing information received from command-line arguments
 *
 * @param array $arguments
 */
PHP_METHOD(Phalcon_CLI_Router, handle){

	zval *arguments = NULL, *namespace_name, *module_name = NULL, *task_name = NULL, *action_name = NULL;

	PHALCON_MM_GROW();

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

	if (!arguments) {
		PHALCON_INIT_VAR(arguments);
		array_init(arguments);
	} else {
		PHALCON_SEPARATE_PARAM(arguments);
	}

	if (Z_TYPE_P(arguments) != IS_ARRAY) { 
		PHALCON_THROW_EXCEPTION_STR(phalcon_cli_router_exception_ce, "Arguments must be an Array");
		return;
	}

	PHALCON_INIT_VAR(module_name);

	PHALCON_INIT_VAR(namespace_name);

	PHALCON_INIT_VAR(task_name);

	PHALCON_INIT_VAR(action_name);

	/** 
	 * Check for a module
	 */
	if (phalcon_array_isset_string(arguments, SS("module"))) {
		PHALCON_OBS_NVAR(module_name);
		phalcon_array_fetch_string(&module_name, arguments, SL("module"), PH_NOISY);
		phalcon_array_unset_string(&arguments, SS("module"), PH_COPY);
	}

	/**
	 * Check for a namespace
	 */
	if (phalcon_array_isset_string(arguments, SS("namespace"))) {
		PHALCON_OBS_NVAR(namespace_name);
		phalcon_array_fetch_string(&namespace_name, arguments, SL("namespace"), PH_NOISY);
		phalcon_array_unset_string(&arguments, SS("namespace"), PH_COPY);
	}

	/** 
	 * Check for a task
	 */
	if (phalcon_array_isset_string(arguments, SS("task"))) {
		PHALCON_OBS_NVAR(task_name);
		phalcon_array_fetch_string(&task_name, arguments, SL("task"), PH_NOISY);
		phalcon_array_unset_string(&arguments, SS("task"), PH_COPY);
	}

	/** 
	 * Check for an action
	 */
	if (phalcon_array_isset_string(arguments, SS("action"))) {
		PHALCON_OBS_NVAR(action_name);
		phalcon_array_fetch_string(&action_name, arguments, SL("action"), PH_NOISY);
		phalcon_array_unset_string(&arguments, SS("action"), PH_COPY);
	}

	phalcon_update_property_this(this_ptr, SL("_module"), module_name TSRMLS_CC);
	phalcon_update_property_this(this_ptr, SL("_namespace"), namespace_name TSRMLS_CC);
	phalcon_update_property_this(this_ptr, SL("_task"), task_name TSRMLS_CC);
	phalcon_update_property_this(this_ptr, SL("_action"), action_name TSRMLS_CC);
	phalcon_update_property_this(this_ptr, SL("_params"), arguments TSRMLS_CC);

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


示例2: PHP_METHOD

/**
 * Builds a HTML FORM tag
 *
 * <code>
 * echo Phalcon\Tag::form("posts/save");
 * echo Phalcon\Tag::form(array("posts/save", "method" => "post"));
 * </code>
 *
 * Volt syntax:
 * <code>
 * {{ form("posts/save") }}
 * {{ form("posts/save", "method": "post") }}
 * </code>
 *
 * @param array $parameters
 * @return string
 */
PHP_METHOD(Phalcon_Tag, form){

	zval *parameters = NULL, *params = NULL, *params_action = NULL, *action = NULL;
	zval *url, *code, *avalue = NULL, *key = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &parameters);
	
	if (!parameters) {
		PHALCON_INIT_VAR(parameters);
	} else {
		PHALCON_SEPARATE_PARAM(parameters);
	}
	
	if (Z_TYPE_P(parameters) != IS_ARRAY) { 
		PHALCON_INIT_VAR(params);
		array_init_size(params, 1);
		phalcon_array_append(&params, parameters, PH_SEPARATE TSRMLS_CC);
	} else {
		PHALCON_CPY_WRT(params, parameters);
	}
	if (phalcon_array_isset_long(params, 0)) {
		PHALCON_OBS_VAR(params_action);
		phalcon_array_fetch_long(&params_action, params, 0, PH_NOISY_CC);
	} else {
		if (phalcon_array_isset_string(params, SS("action"))) {
			PHALCON_OBS_NVAR(params_action);
			phalcon_array_fetch_string(&params_action, params, SL("action"), PH_NOISY_CC);
		} else {
			PHALCON_INIT_NVAR(params_action);
		}
	}
	
	/** 
	 * By default the method is POST
	 */
	if (!phalcon_array_isset_string(params, SS("method"))) {
		phalcon_array_update_string_string(&params, SL("method"), SL("post"), PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(action);
	if (Z_TYPE_P(params_action) != IS_NULL) {
		PHALCON_INIT_VAR(url);
		PHALCON_CALL_SELF(url, this_ptr, "geturlservice");
	
		PHALCON_CALL_METHOD_PARAMS_1(action, url, "get", params_action);
	}
	
	/** 
	 * Check for extra parameters
	 */
	if (phalcon_array_isset_string(params, SS("parameters"))) {
		PHALCON_OBS_NVAR(parameters);
		phalcon_array_fetch_string(&parameters, params, SL("parameters"), PH_NOISY_CC);
		PHALCON_SCONCAT_SV(action, "?", parameters);
	}
	
	if (Z_TYPE_P(action) != IS_NULL) {
		phalcon_array_update_string(&params, SL("action"), &action, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(code);
	ZVAL_STRING(code, "<form", 1);
	
	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(avalue);
	
		if (Z_TYPE_P(key) != IS_LONG) {
			PHALCON_SCONCAT_SVSVS(code, " ", key, "=\"", avalue, "\"");
		}
	
		zend_hash_move_forward_ex(ah0, &hp0);
	}
//.........这里部分代码省略.........
开发者ID:angkatan21,项目名称:cphalcon,代码行数:101,代码来源:tag.c


示例3: PHP_METHOD

/**
 * Returns a cached content
 *
 * @param int|string $keyName
 * @param   long $lifetime
 * @return  mixed
 */
PHP_METHOD(Phalcon_Cache_Backend_File, get){

	zval *key_name, *lifetime = NULL, *options, *prefix, *filtered;
	zval *prefixed_key, *cache_dir, *cache_file;
	zval *frontend, *time, *ttl = NULL, *modified_time, *difference;
	zval *not_expired, *cached_content, *processed;

	PHALCON_MM_GROW();

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

	if (!lifetime) {
		PHALCON_INIT_NVAR(lifetime);
	}
	
	PHALCON_INIT_VAR(options);
	phalcon_read_property(&options, this_ptr, SL("_options"), PH_NOISY_CC);
	
	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_VAR(prefixed_key);
	PHALCON_CONCAT_VV(prefixed_key, prefix, filtered);
	phalcon_update_property_zval(this_ptr, SL("_lastKey"), prefixed_key TSRMLS_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, prefixed_key);
	if (phalcon_file_exists(cache_file TSRMLS_CC) == SUCCESS) {
		PHALCON_INIT_VAR(frontend);
		phalcon_read_property(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
	
		/** 
		 * Check if the file has expired
		 */
		PHALCON_INIT_VAR(time);
		PHALCON_CALL_FUNC(time, "time");
		if (Z_TYPE_P(lifetime) == IS_NULL) {
			PHALCON_INIT_VAR(ttl);
			PHALCON_CALL_METHOD(ttl, frontend, "getlifetime", PH_NO_CHECK);
		} else {
			PHALCON_CPY_WRT(ttl, lifetime);
		}
	
		PHALCON_INIT_VAR(modified_time);
		PHALCON_CALL_FUNC_PARAMS_1(modified_time, "filemtime", cache_file);
	
		PHALCON_INIT_VAR(difference);
		sub_function(difference, time, ttl TSRMLS_CC);
	
		PHALCON_INIT_VAR(not_expired);
		is_smaller_function(not_expired, difference, modified_time TSRMLS_CC);
	
		/** 
		 * The content is only retrieved if the content has not expired
		 */
		if (PHALCON_IS_TRUE(not_expired)) {
			PHALCON_INIT_VAR(cached_content);
			PHALCON_CALL_FUNC_PARAMS_1(cached_content, "file_get_contents", cache_file);
	
			PHALCON_INIT_VAR(processed);
			PHALCON_CALL_METHOD_PARAMS_1(processed, frontend, "afterretrieve", cached_content, PH_NO_CHECK);
	
			RETURN_CCTOR(processed);
		}
	}
	
	PHALCON_MM_RESTORE();
	RETURN_NULL();
}
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:85,代码来源:file.c


示例4: PHP_METHOD

/**
 * Routes to a controller/action using a string or array uri
 *
 * @param string $uri
 */
PHP_METHOD(Phalcon_Dispatcher, forward){

	zval *uri = NULL, *parts = NULL, *params = NULL, *value = NULL, *key = NULL;
	zval *c0 = NULL;
	zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;
	zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL;
	zval *a0 = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;
	char *hash_index;
	uint hash_index_len;
	ulong hash_num;
	int hash_type;
	int eval_int;

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

	if (Z_TYPE_P(uri) == IS_ARRAY) { 
		PHALCON_CPY_WRT(parts, uri);
	} else {
		PHALCON_INIT_VAR(c0);
		ZVAL_STRING(c0, "/", 1);
		PHALCON_ALLOC_ZVAL_MM(r0);
		phalcon_fast_explode(r0, c0, uri TSRMLS_CC);
		PHALCON_CPY_WRT(parts, r0);
	}
	eval_int = phalcon_array_isset_long(parts, 0);
	if (eval_int) {
		PHALCON_ALLOC_ZVAL_MM(r1);
		phalcon_array_fetch_long(&r1, parts, 0, PHALCON_NOISY TSRMLS_CC);
		PHALCON_ALLOC_ZVAL_MM(r2);
		phalcon_filter_alphanum(r2, r1);
		phalcon_update_property_zval(this_ptr, SL("_controllerName"), r2 TSRMLS_CC);
		PHALCON_SEPARATE(parts);
		phalcon_array_unset_long(parts, 0);
	} else {
		eval_int = phalcon_array_isset_string(parts, SL("controller")+1);
		if (eval_int) {
			PHALCON_ALLOC_ZVAL_MM(r3);
			phalcon_array_fetch_string(&r3, parts, SL("controller"), PHALCON_NOISY TSRMLS_CC);
			PHALCON_ALLOC_ZVAL_MM(r4);
			phalcon_filter_alphanum(r4, r3);
			phalcon_update_property_zval(this_ptr, SL("_controllerName"), r4 TSRMLS_CC);
		} else {
			PHALCON_ALLOC_ZVAL_MM(r5);
			PHALCON_CALL_METHOD(r5, this_ptr, "getcontrollername", PHALCON_NO_CHECK);
			phalcon_update_property_zval(this_ptr, SL("_controllerName"), r5 TSRMLS_CC);
		}
	}
	
	eval_int = phalcon_array_isset_long(parts, 1);
	if (eval_int) {
		PHALCON_ALLOC_ZVAL_MM(r6);
		phalcon_array_fetch_long(&r6, parts, 1, PHALCON_NOISY TSRMLS_CC);
		PHALCON_ALLOC_ZVAL_MM(r7);
		phalcon_filter_alphanum(r7, r6);
		phalcon_update_property_zval(this_ptr, SL("_actionName"), r7 TSRMLS_CC);
		
		PHALCON_ALLOC_ZVAL_MM(r8);
		phalcon_array_fetch_long(&r8, parts, 1, PHALCON_NOISY TSRMLS_CC);
		phalcon_update_property_zval(this_ptr, SL("_actionName"), r8 TSRMLS_CC);
		PHALCON_SEPARATE(parts);
		phalcon_array_unset_long(parts, 1);
	} else {
		eval_int = phalcon_array_isset_string(parts, SL("action")+1);
		if (eval_int) {
			PHALCON_ALLOC_ZVAL_MM(r9);
			phalcon_array_fetch_string(&r9, parts, SL("action"), PHALCON_NOISY TSRMLS_CC);
			PHALCON_ALLOC_ZVAL_MM(r10);
			phalcon_filter_alphanum(r10, r9);
			phalcon_update_property_zval(this_ptr, SL("_actionName"), r10 TSRMLS_CC);
		} else {
			PHALCON_ALLOC_ZVAL_MM(r11);
			PHALCON_CALL_METHOD(r11, this_ptr, "getactionname", PHALCON_NO_CHECK);
			phalcon_update_property_zval(this_ptr, SL("_actionName"), r11 TSRMLS_CC);
		}
	}
	
	PHALCON_INIT_VAR(a0);
	array_init(a0);
	PHALCON_CPY_WRT(params, a0);
	if (phalcon_valid_foreach(parts TSRMLS_CC)) {
		ah0 = Z_ARRVAL_P(parts);
		zend_hash_internal_pointer_reset_ex(ah0, &hp0);
		fes_e10f_1:
		if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
			goto fee_e10f_1;
		} else {
			PHALCON_INIT_VAR(key);
//.........这里部分代码省略.........
开发者ID:rcpsec,项目名称:cphalcon,代码行数:101,代码来源:dispatcher.c


示例5: PHP_METHOD

/**
 * Restores the internal state of a Phalcon\Db\Column object
 *
 * @param array $data
 * @return \Phalcon\Db\Column
 */
PHP_METHOD(Phalcon_Db_Column, __set_state){

	zval *data, *definition, *column_name, *column_type;
	zval *not_null, *primary, *size, *dunsigned, *after;
	zval *is_numeric, *first, *bind_type, *column;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &data);
	
	if (Z_TYPE_P(data) != IS_ARRAY) { 
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column state must be an array");
		return;
	}
	
	PHALCON_INIT_VAR(definition);
	array_init(definition);
	if (!phalcon_array_isset_string(data, SS("_columnName"))) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required");
		return;
	}
	
	PHALCON_OBS_VAR(column_name);
	phalcon_array_fetch_string(&column_name, data, SL("_columnName"), PH_NOISY_CC);
	if (phalcon_array_isset_string(data, SS("_type"))) {
		PHALCON_OBS_VAR(column_type);
		phalcon_array_fetch_string(&column_type, data, SL("_type"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_notNull"))) {
		PHALCON_OBS_VAR(not_null);
		phalcon_array_fetch_string(&not_null, data, SL("_notNull"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("notNull"), &not_null, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_primary"))) {
		PHALCON_OBS_VAR(primary);
		phalcon_array_fetch_string(&primary, data, SL("_primary"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_size"))) {
		PHALCON_OBS_VAR(size);
		phalcon_array_fetch_string(&size, data, SL("_size"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_unsigned"))) {
		PHALCON_OBS_VAR(dunsigned);
		phalcon_array_fetch_string(&dunsigned, data, SL("_unsigned"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_after"))) {
		PHALCON_OBS_VAR(after);
		phalcon_array_fetch_string(&after, data, SL("_after"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_isNumeric"))) {
		PHALCON_OBS_VAR(is_numeric);
		phalcon_array_fetch_string(&is_numeric, data, SL("_isNumeric"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_first"))) {
		PHALCON_OBS_VAR(first);
		phalcon_array_fetch_string(&first, data, SL("_first"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(data, SS("_bindType"))) {
		PHALCON_OBS_VAR(bind_type);
		phalcon_array_fetch_string(&bind_type, data, SL("_bindType"), PH_NOISY_CC);
		phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(column);
	object_init_ex(column, phalcon_db_column_ce);
	phalcon_call_method_p2_noret(column, "__construct", column_name, definition);
	
	RETURN_CTOR(column);
}
开发者ID:RSivakov,项目名称:cphalcon,代码行数:90,代码来源:column.c


示例6: PHP_METHOD

/**
 * Builds a SELECT statement
 *
 * @param array $definition
 * @return string
 */
PHP_METHOD(Phalcon_Db_Dialect, select){

	zval *definition, *escape_char = NULL, *columns, *selected_columns;
	zval *column = NULL, *column_item = NULL, *column_sql = NULL, *columns_sql = NULL;
	zval *column_domain = NULL, *column_domain_sql = NULL, *column_alias = NULL;
	zval *column_alias_sql = NULL, *tables, *selected_tables;
	zval *table = NULL, *sql_table = NULL, *tables_sql = NULL, *sql, *joins;
	zval *join = NULL, *type = NULL, *sql_join = NULL, *join_conditions_array = NULL;
	zval *join_expressions = NULL, *join_condition = NULL, *join_expression = NULL;
	zval *join_conditions = NULL, *where_conditions;
	zval *where_expression, *group_items, *group_fields;
	zval *group_field = NULL, *group_expression = NULL, *group_sql;
	zval *group_clause, *having_conditions, *having_expression;
	zval *order_fields, *order_items, *order_item = NULL;
	zval *order_expression = NULL, *order_sql_item = NULL, *sql_order_type = NULL;
	zval *order_sql_item_type = NULL, *order_sql, *limit_value;
	zval *number, *offset;
	HashTable *ah0, *ah1, *ah2, *ah3, *ah4, *ah5;
	HashPosition hp0, hp1, hp2, hp3, hp4, hp5;
	zval **hd;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &definition) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (Z_TYPE_P(definition) != IS_ARRAY) { 
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Invalid SELECT definition");
		return;
	}
	if (!phalcon_array_isset_string(definition, SS("tables"))) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The index 'tables' is required in the definition array");
		return;
	}
	
	if (!phalcon_array_isset_string(definition, SS("columns"))) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array");
		return;
	}
	
	if (PHALCON_GLOBAL(db).escape_identifiers) {
		PHALCON_OBS_VAR(escape_char);
		phalcon_read_property(&escape_char, this_ptr, SL("_escapeChar"), PH_NOISY_CC);
	} else {
		PHALCON_INIT_NVAR(escape_char);
	}
	
	PHALCON_OBS_VAR(columns);
	phalcon_array_fetch_string(&columns, definition, SL("columns"), PH_NOISY_CC);
	if (Z_TYPE_P(columns) == IS_ARRAY) { 
	
		PHALCON_INIT_VAR(selected_columns);
		array_init(selected_columns);
	
		if (!phalcon_is_iterable(columns, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
			return;
		}
	
		while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
	
			PHALCON_GET_FOREACH_VALUE(column);
	
			/** 
			 * Escape column name
			 */
			PHALCON_OBS_NVAR(column_item);
			phalcon_array_fetch_long(&column_item, column, 0, PH_NOISY_CC);
			if (Z_TYPE_P(column_item) == IS_ARRAY) { 
				PHALCON_INIT_NVAR(column_sql);
				PHALCON_CALL_METHOD_PARAMS_2(column_sql, this_ptr, "getsqlexpression", column_item, escape_char);
			} else {
				if (PHALCON_IS_STRING(column_item, "*")) {
					PHALCON_CPY_WRT(column_sql, column_item);
				} else {
					if (PHALCON_GLOBAL(db).escape_identifiers) {
						PHALCON_INIT_NVAR(column_sql);
						PHALCON_CONCAT_VVV(column_sql, escape_char, column_item, escape_char);
					} else {
						PHALCON_CPY_WRT(columns_sql, column_item);
					}
				}
			}
	
			/** 
			 * Escape column domain
			 */
			PHALCON_OBS_NVAR(column_domain);
			phalcon_array_fetch_long(&column_domain, column, 1, PH_NOISY_CC);
			if (zend_is_true(column_domain)) {
				if (PHALCON_GLOBAL(db).escape_identifiers) {
					PHALCON_INIT_NVAR(column_domain_sql);
					PHALCON_CONCAT_VVVSV(column_domain_sql, escape_char, column_domain, escape_char, ".", column_sql);
				} else {
//.........这里部分代码省略.........
开发者ID:Gildus,项目名称:cphalcon,代码行数:101,代码来源:dialect.c


示例7: PHP_METHOD

/**
 * Phalcon\Db\Reference constructor
 *
 * @param string $referenceName
 * @param array $definition
 */
PHP_METHOD(Phalcon_Db_Reference, __construct){

	zval *reference_name = NULL, *definition = NULL, *referenced_table = NULL;
	zval *columns = NULL, *referenced_columns = NULL, *schema = NULL;
	zval *referenced_schema = NULL, *number_columns = NULL;
	zval *number_referenced_columns = NULL;
	zval *r0 = NULL;
	int eval_int;

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

	phalcon_update_property_zval(this_ptr, SL("_referenceName"), reference_name TSRMLS_CC);
	eval_int = phalcon_array_isset_string(definition, SL("referencedTable")+1);
	if (eval_int) {
		PHALCON_INIT_VAR(referenced_table);
		phalcon_array_fetch_string(&referenced_table, definition, SL("referencedTable"), PH_NOISY_CC);
		phalcon_update_property_zval(this_ptr, SL("_referencedTable"), referenced_table TSRMLS_CC);
	} else {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Referenced table is required");
		return;
	}
	
	eval_int = phalcon_array_isset_string(definition, SL("columns")+1);
	if (eval_int) {
		PHALCON_INIT_VAR(columns);
		phalcon_array_fetch_string(&columns, definition, SL("columns"), PH_NOISY_CC);
		phalcon_update_property_zval(this_ptr, SL("_columns"), columns TSRMLS_CC);
	} else {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Foreign key columns are required");
		return;
	}
	
	eval_int = phalcon_array_isset_string(definition, SL("referencedColumns")+1);
	if (eval_int) {
		PHALCON_INIT_VAR(referenced_columns);
		phalcon_array_fetch_string(&referenced_columns, definition, SL("referencedColumns"), PH_NOISY_CC);
		phalcon_update_property_zval(this_ptr, SL("_referencedColumns"), referenced_columns TSRMLS_CC);
	} else {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Referenced columns of the foreign key are required");
		return;
	}
	
	eval_int = phalcon_array_isset_string(definition, SL("schema")+1);
	if (eval_int) {
		PHALCON_INIT_VAR(schema);
		phalcon_array_fetch_string(&schema, definition, SL("schema"), PH_NOISY_CC);
		phalcon_update_property_zval(this_ptr, SL("_schema"), schema TSRMLS_CC);
	}
	
	eval_int = phalcon_array_isset_string(definition, SL("referencedSchema")+1);
	if (eval_int) {
		PHALCON_INIT_VAR(referenced_schema);
		phalcon_array_fetch_string(&referenced_schema, definition, SL("referencedSchema"), PH_NOISY_CC);
		phalcon_update_property_zval(this_ptr, SL("_referencedSchema"), referenced_schema TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(number_columns);
	phalcon_fast_count(number_columns, columns TSRMLS_CC);
	
	PHALCON_INIT_VAR(number_referenced_columns);
	phalcon_fast_count(number_referenced_columns, referenced_columns TSRMLS_CC);
	
	PHALCON_ALLOC_ZVAL_MM(r0);
	is_not_equal_function(r0, number_columns, number_referenced_columns TSRMLS_CC);
	if (zend_is_true(r0)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Number of columns is not equals than the number of columns referenced");
		return;
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:codeanu,项目名称:cphalcon,代码行数:82,代码来源:reference.c


示例8: PHP_METHOD

/**
 * Renders a view
 *
 * @param string $path
 * @param array $params
 * @return string
 */
PHP_METHOD(Phalcon_Mvc_View_Simple, render){

	zval *path, *params = NULL, *cache, *is_started = NULL, *key = NULL, *lifetime = NULL;
	zval *cache_options, *content = NULL, *view_params;
	zval *merged_params = NULL, *is_fresh;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &path, &params);
	
	if (!params) {
		PHALCON_INIT_VAR(params);
	}
	
	/** 
	 * Create/Get a cache
	 */
	PHALCON_INIT_VAR(cache);
	phalcon_call_method(cache, this_ptr, "getcache");
	if (Z_TYPE_P(cache) == IS_OBJECT) {
	
		/** 
		 * Check if the cache is started, the first time a cache is started we start the
		 * cache
		 */
		PHALCON_INIT_VAR(is_started);
		phalcon_call_method(is_started, cache, "isstarted");
		if (PHALCON_IS_FALSE(is_started)) {
	
			PHALCON_INIT_VAR(key);
	
			PHALCON_INIT_VAR(lifetime);
	
			PHALCON_OBS_VAR(cache_options);
			phalcon_read_property_this(&cache_options, this_ptr, SL("_cacheOptions"), PH_NOISY_CC);
	
			/** 
			 * Check if the user has defined a different options to the default
			 */
			if (Z_TYPE_P(cache_options) == IS_ARRAY) { 
				if (phalcon_array_isset_string(cache_options, SS("key"))) {
					PHALCON_OBS_NVAR(key);
					phalcon_array_fetch_string(&key, cache_options, SL("key"), PH_NOISY);
				}
				if (phalcon_array_isset_string(cache_options, SS("lifetime"))) {
					PHALCON_OBS_NVAR(lifetime);
					phalcon_array_fetch_string(&lifetime, cache_options, SL("lifetime"), PH_NOISY);
				}
			}
	
			/** 
			 * If a cache key is not set we create one using a md5
			 */
			if (Z_TYPE_P(key) == IS_NULL) {
				PHALCON_INIT_NVAR(key);
				phalcon_md5(key, path);
			}
	
			/** 
			 * We start the cache using the key set
			 */
			PHALCON_INIT_VAR(content);
			phalcon_call_method_p2(content, cache, "start", key, lifetime);
			if (Z_TYPE_P(content) != IS_NULL) {
				phalcon_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC);
				RETURN_CCTOR(content);
			}
		}
	}
	
	/** 
	 * Create a virtual symbol table
	 */
	phalcon_create_symbol_table(TSRMLS_C);
	
	phalcon_ob_start(TSRMLS_C);
	
	PHALCON_OBS_VAR(view_params);
	phalcon_read_property_this(&view_params, this_ptr, SL("_viewParams"), PH_NOISY_CC);
	
	/** 
	 * Merge parameters
	 */
	if (Z_TYPE_P(params) == IS_ARRAY) { 
		if (Z_TYPE_P(view_params) == IS_ARRAY) { 
			PHALCON_INIT_VAR(merged_params);
			phalcon_fast_array_merge(merged_params, &view_params, &params TSRMLS_CC);
		} else {
			PHALCON_CPY_WRT(merged_params, params);
		}
	} else {
		PHALCON_CPY_WRT(merged_params, view_params);
	}
//.........这里部分代码省略.........
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:101,代码来源:simple.c


示例9: PHP_METHOD

/**
 * Phalcon\Mvc\Model\Query\Builder constructor
 *
 * @param array $params
 */
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct){

	zval *params = NULL, *conditions = NULL, *columns, *group_clause;
	zval *having_clause, *order_clause, *limit_clause;
	zval *for_update, *shared_lock;

	PHALCON_MM_GROW();

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

	if (!params) {
		PHALCON_INIT_VAR(params);
	}
	
	if (Z_TYPE_P(params) == IS_ARRAY) { 
	
		/** 
		 * Process conditions
		 */
		if (phalcon_array_isset_long(params, 0)) {
			PHALCON_OBS_VAR(conditions);
			phalcon_array_fetch_long(&conditions, params, 0, PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_conditions"), conditions TSRMLS_CC);
		} else {
			if (phalcon_array_isset_string(params, SS("conditions"))) {
				PHALCON_OBS_NVAR(conditions);
				phalcon_array_fetch_string(&conditions, params, SL("conditions"), PH_NOISY_CC);
				phalcon_update_property_zval(this_ptr, SL("_conditions"), conditions TSRMLS_CC);
			}
		}
	
		/** 
		 * Assign COLUMNS clause
		 */
		if (phalcon_array_isset_string(params, SS("columns"))) {
			PHALCON_OBS_VAR(columns);
			phalcon_array_fetch_string(&columns, params, SL("columns"), PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_columns"), columns TSRMLS_CC);
		}
	
		/** 
		 * Assign GROUP clause
		 */
		if (phalcon_array_isset_string(params, SS("group"))) {
			PHALCON_OBS_VAR(group_clause);
			phalcon_array_fetch_string(&group_clause, params, SL("group"), PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_group"), group_clause TSRMLS_CC);
		}
	
		/** 
		 * Assign HAVING clause
		 */
		if (phalcon_array_isset_string(params, SS("having"))) {
			PHALCON_OBS_VAR(having_clause);
			phalcon_array_fetch_string(&having_clause, params, SL("having"), PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_group"), having_clause TSRMLS_CC);
		}
	
		/** 
		 * Assign ORDER clause
		 */
		if (phalcon_array_isset_string(params, SS("order"))) {
			PHALCON_OBS_VAR(order_clause);
			phalcon_array_fetch_string(&order_clause, params, SL("order"), PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_order"), order_clause TSRMLS_CC);
		}
	
		/** 
		 * Assign LIMIT clause
		 */
		if (phalcon_array_isset_string(params, SS("limit"))) {
			PHALCON_OBS_VAR(limit_clause);
			phalcon_array_fetch_string(&limit_clause, params, SL("limit"), PH_NOISY_CC);
			phalcon_update_property_zval(this_ptr, SL("_limit"), limit_clause TSRMLS_CC);
		}
	
		/** 
		 * Assign FOR UPDATE clause
		 */
		if (phalcon_array_isset_string(params, SS("for_update"))) {
	
			PHALCON_OBS_VAR(for_update);
			phalcon_array_fetch_string(&for_update, params, SL("for_update"), PH_NOISY_CC);
			if (zend_is_true(for_update)) {
				phalcon_update_property_bool(this_ptr, SL("_forUpdate"), 1 TSRMLS_CC);
			}
		}
	
		/** 
		 * Assign SHARED LOCK clause
		 */
		if (phalcon_array_isset_string(params, SS("shared_lock"))) {
	
//.........这里部分代码省略.........
开发者ID:BlueShark,项目名称:cphalcon,代码行数:101,代码来源:builder.c


示例10: PHP_METHOD

/**
 * Reads the cookie-related info from the SESSION to restore the cookie as it was set
 * This method is automatically called internally so normally you don't need to call it
 *
 * @return Phalcon\Http\Cookie
 */
PHP_METHOD(Phalcon_Http_Cookie, restore){

	zval *restored, *dependency_injector, *service;
	zval *session, *name, *key, *definition, *expire, *domain;
	zval *path, *secure, *http_only;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(restored);
	phalcon_read_property_this(&restored, this_ptr, SL("_restored"), PH_NOISY_CC);
	if (!zend_is_true(restored)) {
	
		PHALCON_OBS_VAR(dependency_injector);
		phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
		if (Z_TYPE_P(dependency_injector) == IS_OBJECT) {
	
			PHALCON_INIT_VAR(service);
			ZVAL_STRING(service, "session", 1);
	
			PHALCON_INIT_VAR(session);
			phalcon_call_method_p1(session, dependency_injector, "getshared", service);
	
			PHALCON_OBS_VAR(name);
			phalcon_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC);
	
			PHALCON_INIT_VAR(key);
			PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name);
	
			PHALCON_INIT_VAR(definition);
			phalcon_call_method_p1(definition, session, "get", key);
			if (Z_TYPE_P(definition) == IS_ARRAY) { 
				if (phalcon_array_isset_string(definition, SS("expire"))) {
					PHALCON_OBS_VAR(expire);
					phalcon_array_fetch_string(&expire, definition, SL("expire"), PH_NOISY);
					phalcon_update_property_this(this_ptr, SL("_expire"), expire TSRMLS_CC);
				}
				if (phalcon_array_isset_string(definition, SS("domain"))) {
					PHALCON_OBS_VAR(domain);
					phalcon_array_fetch_string(&domain, definition, SL("domain"), PH_NOISY);
					phalcon_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC);
				}
	
				if (phalcon_array_isset_string(definition, SS("path"))) {
					PHALCON_OBS_VAR(path);
					phalcon_array_fetch_string(&path, definition, SL("path"), PH_NOISY);
					phalcon_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC);
				}
	
				if (phalcon_array_isset_string(definition, SS("secure"))) {
					PHALCON_OBS_VAR(secure);
					phalcon_array_fetch_string(&secure, definition, SL("secure"), PH_NOISY);
					phalcon_update_property_this(this_ptr, SL("_secure"), secure TSRMLS_CC);
				}
	
				if (phalcon_array_isset_string(definition, SS("httpOnly"))) {
					PHALCON_OBS_VAR(http_only);
					phalcon_array_fetch_string(&http_only, definition, SL("httpOnly"), PH_NOISY);
					phalcon_update_property_this(this_ptr, SL("_httpOnly"), http_only TSRMLS_CC);
				}
			}
		}
	
		phalcon_update_property_bool(this_ptr, SL("_restored"), 1 TSRMLS_CC);
	}
	
	RETURN_THIS();
}
开发者ID:Diego-Brocanelli,项目名称:cphalcon,代码行数:73,代码来源:cookie.c


示例11: PHP_METHOD

/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection
 *
 *<code>
 * //Make a connection
 * $connection = new Phalcon\Db\Adapter\Pdo\Mysql(array(
 *  'host' => '192.168.0.11',
 *  'username' => 'sigma',
 *  'password' => 'secret',
 *  'dbname' => 'blog',
 * ));
 *
 * //Reconnect
 * $connection->connect();
 * </code>
 *
 * @param 	array $descriptor
 * @return 	boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect){

	zval *descriptor = NULL, *username = NULL, *password = NULL, *dsn_parts;
	zval *value = NULL, *key = NULL, *dsn_attribute = NULL, *dsn_attributes = NULL;
	zval *pdo_type, *dsn, *options = NULL, *persistent, *pdo;
	zend_class_entry *ce;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &descriptor) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (!descriptor) {
		PHALCON_INIT_VAR(descriptor);
	} else {
		PHALCON_SEPARATE_PARAM(descriptor);
	}

	if (Z_TYPE_P(descriptor) == IS_NULL) {
		PHALCON_OBS_NVAR(descriptor);
		phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY TSRMLS_CC);
	}

	/**
	 * Check for a username or use null as default
	 */
	if (phalcon_array_isset_string(descriptor, SS("username"))) {
		PHALCON_OBS_VAR(username);
		phalcon_array_fetch_string(&username, descriptor, SL("username"), PH_NOISY);
		phalcon_array_unset_string(&descriptor, SS("username"), PH_COPY);
	} else {
		PHALCON_INIT_NVAR(username);
	}

	/**
	 * Check for a password or use null as default
	 */
	if (phalcon_array_isset_string(descriptor, SS("password"))) {
		PHALCON_OBS_VAR(password);
		phalcon_array_fetch_string(&password, descriptor, SL("password"), PH_NOISY);
		phalcon_array_unset_string(&descriptor, SS("password"), PH_COPY);
	} else {
		PHALCON_INIT_NVAR(password);
	}

	/**
	 * Check if the developer has defined custom options or create one from scratch
	 */
	if (phalcon_array_isset_string(descriptor, SS("options"))) {
		PHALCON_OBS_VAR(options);
		phalcon_array_fetch_string(&options, descriptor, SL("options"), PH_NOISY);
		phalcon_array_unset_string(&descriptor, SS("options"), PH_COPY);
	} else {
		PHALCON_INIT_NVAR(options);
		array_init(options);
	}

	/**
	 * Remove the dialectClass from the descriptor if any
	 */
	if (phalcon_array_isset_string(descriptor, SS("dialectClass"))) {
		phalcon_array_unset_string(&descriptor, SS("dialectClass"), PH_COPY);
	}

	/**
	 * Check if the user has defined a custom dsn
	 */
	if (!phalcon_array_isset_string(descriptor, SS("dsn"))) {

		PHALCON_INIT_VAR(dsn_parts);
		array_init(dsn_parts);

		phalcon_is_iterable(descriptor, &ah0, &hp0, 0, 0);

		while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {

//.........这里部分代码省略.........
开发者ID:banketree,项目名称:cphalcon,代码行数:101,代码来源:pdo.c


示例12: PHP_METHOD

/**
 * Appends a condition to the current conditions using an OR operator
 *
 * @param string $conditions
 * @param array $bindParams
 * @param array $bindTypes
 * @return Phalcon\Mvc\Model\Criteria
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere){

	zval *conditions, *bind_params = NULL, *bind_types = NULL;
	zval *params = NULL, *current_conditions, *new_conditions = NULL;
	zval *current_bind_params, *merged_params = NULL;
	zval *current_bind_types, *merged_params_types = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &conditions, &bind_params, &bind_types);
	
	if (!bind_params) {
		PHALCON_INIT_VAR(bind_params);
	}
	
	if (!bind_types) {
		PHALCON_INIT_VAR(bind_types);
	}
	
	if (Z_TYPE_P(conditions) != IS_STRING) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Conditions must be string");
		return;
	}
	
	PHALCON_OBS_VAR(params);
	phalcon_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
	if (phalcon_array_isset_string(params, SS("conditions"))) {
		PHALCON_OBS_VAR(current_conditions);
		phalcon_array_fetch_string(&current_conditions, params, SL("conditions"), PH_NOISY_CC);
	
		PHALCON_INIT_VAR(new_conditions);
		PHALCON_CONCAT_SVSVS(new_conditions, "(", current_conditions, ") OR (", conditions, ")");
	} else {
		PHALCON_CPY_WRT(new_conditions, conditions);
	}
	
	phalcon_update_property_array_string(this_ptr, SL("_params"), SS("conditions"), new_conditions TSRMLS_CC);
	
	/** 
	 * Update or merge existing bound parameters
	 */
	if (Z_TYPE_P(bind_params) == IS_ARRAY) { 
	
		PHALCON_OBS_NVAR(params);
		phalcon_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
		if (phalcon_array_isset_string(params, SS("bind"))) {
			PHALCON_OBS_VAR(current_bind_params);
			phalcon_array_fetch_string(&current_bind_params, params, SL("bind"), PH_NOISY_CC);
	
			PHALCON_INIT_VAR(merged_params);
			phalcon_fast_array_merge(merged_params, &current_bind_params, &bind_params TSRMLS_CC);
		} else {
			PHALCON_CPY_WRT(merged_params, bind_params);
		}
	
		phalcon_update_property_array_string(this_ptr, SL("_params"), SS("bind"), merged_params TSRMLS_CC);
	}
	
	/** 
	 * Update or merge existing bind types parameters
	 */
	if (Z_TYPE_P(bind_types) == IS_ARRAY) { 
	
		PHALCON_OBS_NVAR(params);
		phalcon_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
		if (phalcon_array_isset_string(params, SS("bindTypes"))) {
			PHALCON_OBS_VAR(current_bind_types);
			phalcon_array_fetch_string(&current_bind_types, params, SL("bindTypes"), PH_NOISY_CC);
	
			PHALCON_INIT_VAR(merged_params_types);
			phalcon_fast_array_merge(merged_params_types, &current_bind_types, &bind_types TSRMLS_CC);
		} else {
			PHALCON_CPY_WRT(merged_params_types, bind_types);
		}
	
		phalcon_update_property_array_string(this_ptr, SL("_params"), SS("bindTypes"), merged_params_types TSRMLS_CC);
	}
	
	RETURN_THIS();
}
开发者ID:RSivakov,项目名称:cphalcon,代码行数:88,代码来源:criteria.c


示例13: PHP_METHOD

/**
 * Generates a SELECT tag
 *
 * @param array $parameters
 * @param array $data
 */
PHP_METHOD(Phalcon_Tag_Select, selectField){

	zval *parameters, *data = NULL, *params = NULL, *eol, *id = NULL, *name, *value = NULL;
	zval *use_empty = NULL, *empty_value = NULL, *empty_text = NULL, *code;
	zval *avalue = NULL, *key = NULL, *close_option, *options = NULL, *using;
	zval *resultset_options, *array_options;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &parameters, &data) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (!data) {
		PHALCON_INIT_VAR(data);
	}
	
	if (Z_TYPE_P(parameters) != IS_ARRAY) { 
		PHALCON_INIT_VAR(params);
		array_init_size(params, 2);
		phalcon_array_append(&params, parameters, PH_SEPARATE TSRMLS_CC);
		phalcon_array_append(&params, data, PH_SEPARATE TSRMLS_CC);
	} else {
		PHALCON_CPY_WRT(params, parameters);
	}
	
	PHALCON_INIT_VAR(eol);
	zend_get_constant(SL("PHP_EOL"), eol TSRMLS_CC);
	if (!phalcon_array_isset_long(params, 0)) {
		PHALCON_OBS_VAR(id);
		phalcon_array_fetch_string(&id, params, SL("id"), PH_NOISY_CC);
		phalcon_array_update_long(&params, 0, &id, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_OBS_NVAR(id);
	phalcon_array_fetch_long(&id, params, 0, PH_NOISY_CC);
	if (!phalcon_array_isset_string(params, SS("name"))) {
		phalcon_array_update_string(&params, SL("name"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC);
	} else {
		PHALCON_OBS_VAR(name);
		phalcon_array_fetch_string(&name, params, SL("name"), PH_NOISY_CC);
		if (!zend_is_true(name)) {
			phalcon_array_update_string(&params, SL("name"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC);
		}
	}
	
	if (!phalcon_array_isset_string(params, SS("id"))) {
		phalcon_array_update_string(&params, SL("id"), &id, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	if (!phalcon_array_isset_string(params, SS("value"))) {
		PHALCON_INIT_VAR(value);
		PHALCON_CALL_STATIC_PARAMS_2(value, "phalcon\\tag", "getvalue", id, params);
	} else {
		PHALCON_OBS_NVAR(value);
		phalcon_array_fetch_string(&value, params, SL("value"), PH_NOISY_CC);
		PHALCON_SEPARATE(params);
		phalcon_array_unset_string(params, SS("value"));
	}
	
	PHALCON_INIT_VAR(use_empty);
	ZVAL_BOOL(use_empty, 0);
	if (phalcon_array_isset_string(params, SS("useEmpty"))) {
		if (!phalcon_array_isset_string(params, SS("emptyValue"))) {
			PHALCON_INIT_VAR(empty_value);
			ZVAL_STRING(empty_value, "", 1);
		} else {
			PHALCON_OBS_NVAR(empty_value);
			phalcon_array_fetch_string(&empty_value, params, SL("emptyValue"), PH_NOISY_CC);
			PHALCON_SEPARATE(params);
			phalcon_array_unset_string(params, SS("emptyValue"));
		}
		if (!phalcon_array_isset_string(params, SS("emptyText"))) {
			PHALCON_INIT_VAR(empty_text);
			ZVAL_STRING(empty_text, "Choose...", 1);
		} else {
			PHALCON_OBS_NVAR(empty_text);
			phalcon_array_fetch_string(&empty_text, params, SL("emptyText"), PH_NOISY_CC);
			PHALCON_SEPARATE(params);
			phalcon_array_unset_string(params, SS("emptyText"));
		}
	
		PHALCON_OBS_NVAR(use_empty);
		phalcon_array_fetch_string(&use_empty, params, SL("useEmpty"), PH_NOISY_CC);
		PHALCON_SEPARATE(params);
		phalcon_array_unset_string(params, SS("useEmpty"));
	}
	
	PHALCON_INIT_VAR(code);
	ZVAL_STRING(code, "<select", 1);
	if (Z_TYPE_P(params) == IS_ARRAY) { 
//.........这里部分代码省略.........
开发者ID:Gildus,项目名称:cphalcon,代码行数:101,代码来源:select.c


示例14: PHP_METHOD

/**
 * Returns a slice of the resultset to show in the pagination
 *
 * @return stdClass
 */
PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate){

	zval *show = NULL, *config = NULL, *items = NULL, *page_number = NULL, *zero = NULL, *one = NULL;
	zval *smaller = NULL, *n = NULL, *page = NULL, *last_show_page = NULL, *start = NULL;
	zval *last_page = NULL, *possible_pages = NULL, *total_pages = NULL;
	zval *compare = NULL, *page_items = NULL, *i = NULL, *valid = NULL, *current = NULL, *maximum_pages = NULL;
	zval *next = NULL, *additional_page = NULL, *before = NULL, *remainder = NULL;
	zval *pages_total = NULL;
	zval *r0 = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(show);
	phalcon_read_property(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(config);
	phalcon_read_property(&config, this_ptr, SL("_config"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(items);
	phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(page_number);
	phalcon_read_property(&page_number, this_ptr, SL("_page"), PH_NOISY_CC);
	if (Z_TYPE_P(page_number) == IS_NULL) {
		PHALCON_INIT_VAR(page_number);
		ZVAL_LONG(page_number, 1);
	}
	
	PHALCON_INIT_VAR(zero);
	ZVAL_LONG(zero, 0);
	
	PHALCON_INIT_VAR(one);
	ZVAL_LONG(one, 1);
	
	PHALCON_INIT_VAR(smaller);
	is_smaller_function(smaller, show, zero TSRMLS_CC);
	if (Z_TYPE_P(smaller) == IS_BOOL && Z_BVAL_P(smaller)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less");
		return;
	}
	
	PHALCON_INIT_VAR(n);
	phalcon_fast_count(n, items TSRMLS_CC);
	
	PHALCON_INIT_VAR(page);
	object_init(page);
	
	PHALCON_INIT_VAR(last_show_page);
	sub_function(last_show_page, page_number, one TSRMLS_CC);
	
	PHALCON_INIT_VAR(start);
	mul_function(start, show, last_show_page TSRMLS_CC);
	
	PHALCON_INIT_VAR(last_page);
	sub_function(last_page, n, one TSRMLS_CC);
	
	PHALCON_INIT_VAR(possible_pages);
	div_function(possible_pages, last_page, show TSRMLS_CC);
	
	PHALCON_INIT_VAR(total_pages);
	PHALCON_CALL_FUNC_PARAMS_1(total_pages, "ceil", possible_pages);
	if (Z_TYPE_P(items) != IS_OBJECT) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator");
		return;
	}
	
	if (Z_TYPE_P(page_number) == IS_NULL) {
		PHALCON_INIT_VAR(page_number);
		ZVAL_LONG(page_number, 0);
	}
	
	PHALCON_INIT_VAR(compare);
	is_smaller_function(compare, start, zero TSRMLS_CC);
	if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less");
		return;
	}
	
	PHALCON_INIT_VAR(page_items);
	array_init(page_items);
	
	PHALCON_INIT_VAR(compare);
	is_smaller_function(compare, zero, n TSRMLS_CC);
	if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) {
		PHALCON_INIT_VAR(compare);
		is_smaller_or_equal_function(compare, start, n TSRMLS_CC);
		if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) {
			PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", start, PH_NO_CHECK);
		} else {
			PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", one, PH_NO_CHECK);
			
			PHALCON_INIT_VAR(page_number);
			ZVAL_LONG(page_number, 1);
		}
		
//.........这里部分代码省略.........
开发者ID:crou

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ phalcon_array_isset函数代码示例发布时间:2022-05-30
下一篇:
C++ phalcon_array_fetch函数代码示例发布时间: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