コード例 #1
0
ファイル: ooparams.zep.c プロジェクト: 3axap4eHko/zephir
PHP_METHOD(Test_Oo_OoParams, setNameDefault) {

	zval *name_param = NULL;
	zval *name = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &name_param);

	if (!name_param) {
		ZEPHIR_INIT_VAR(name);
		ZVAL_STRING(name, "peter", 1);
	} else {
		zephir_get_strval(name, name_param);
	}


	RETURN_CTOR(name);

}
コード例 #2
0
ファイル: volt.zep.c プロジェクト: AlloVince/cphalcon
/**
 * Sorts an array
 */
PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, sort) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *value_param = NULL;
	zval *value = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value_param);

	zephir_get_arrval(value, value_param);


	ZEPHIR_MAKE_REF(value);
	ZEPHIR_CALL_FUNCTION(NULL, "asort", NULL, 375, value);
	ZEPHIR_UNREF(value);
	zephir_check_call_status();
	RETURN_CTOR(value);

}
コード例 #3
0
ファイル: status.c プロジェクト: gplanchat/cphalcon
PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages){

	zval *model = NULL, *messages = NULL, *empty_arr = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(model);
	phalcon_read_property(&model, this_ptr, SL("_model"), PH_NOISY_CC);
	if (Z_TYPE_P(model) != IS_NULL) {
		PHALCON_INIT_VAR(messages);
		PHALCON_CALL_METHOD(messages, model, "getmessages", PH_NO_CHECK);
		
		RETURN_CCTOR(messages);
	}
	
	PHALCON_INIT_VAR(empty_arr);
	array_init(empty_arr);
	
	RETURN_CTOR(empty_arr);
}
コード例 #4
0
ファイル: ooparams.zep.c プロジェクト: 3axap4eHko/zephir
PHP_METHOD(Test_Oo_OoParams, setListDefault) {

	zval *someList_param = NULL;
	zval *someList = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &someList_param);

	if (!someList_param) {
		ZEPHIR_INIT_VAR(someList);
		array_init(someList);
	} else {
		zephir_get_arrval(someList, someList_param);
	}


	RETURN_CTOR(someList);

}
コード例 #5
0
/**
 * Replaces placeholders by the values passed
 */
PHP_METHOD(Phalcon_Translate_Interpolator_IndexedArray, replacePlaceholders) {

	zend_bool _0;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *translation_param = NULL, *placeholders = NULL, _1$$3;
	zval *translation = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &translation_param, &placeholders);

	if (unlikely(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(translation_param) == IS_STRING)) {
		zephir_get_strval(translation, translation_param);
	} else {
		ZEPHIR_INIT_VAR(translation);
		ZVAL_EMPTY_STRING(translation);
	}
	if (!placeholders) {
		placeholders = ZEPHIR_GLOBAL(global_null);
	}


	_0 = Z_TYPE_P(placeholders) == IS_ARRAY;
	if (_0) {
		_0 = (zephir_fast_count_int(placeholders TSRMLS_CC)) ? 1 : 0;
	}
	if (_0) {
		ZEPHIR_MAKE_REF(placeholders);
		ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 377, placeholders, translation);
		ZEPHIR_UNREF(placeholders);
		zephir_check_call_status();
		ZEPHIR_SINIT_VAR(_1$$3);
		ZVAL_STRING(&_1$$3, "sprintf", 0);
		ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_1$$3, placeholders);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETURN_CTOR(translation);

}
コード例 #6
0
ファイル: compare.zep.c プロジェクト: dreamsxin/zephir
/**
 * @link https://github.com/phalcon/zephir/issues/411
 */
PHP_METHOD(Test_Compare, testVarWithStringEquals) {

	zval *str_param = NULL;
	zval str;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&str);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &str_param);

	if (UNEXPECTED(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be of the type string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(str_param) == IS_STRING)) {
		zephir_get_strval(&str, str_param);
	} else {
		ZEPHIR_INIT_VAR(&str);
		ZVAL_EMPTY_STRING(&str);
	}


	if (ZEPHIR_IS_STRING_IDENTICAL(&str, "wrong testing")) {
		ZEPHIR_INIT_NVAR(&str);
		ZVAL_STRING(&str, "NOK");
	} else {
		if (ZEPHIR_IS_STRING_IDENTICAL(&str, "another testing")) {
			ZEPHIR_INIT_NVAR(&str);
			ZVAL_STRING(&str, "NOK");
		} else {
			if (ZEPHIR_IS_STRING_IDENTICAL(&str, "testing")) {
				ZEPHIR_INIT_NVAR(&str);
				ZVAL_STRING(&str, "OK");
			} else {
				ZEPHIR_INIT_NVAR(&str);
				ZVAL_STRING(&str, "NOK");
			}
		}
	}
	RETURN_CTOR(&str);

}
コード例 #7
0
ファイル: metadata.zep.c プロジェクト: dschissler/cphalcon
/**
 * Reads meta-data for certain model
 *
 *<code>
 * print_r(
 *     $metaData->readMetaDataIndex(
 *         new Robots(),
 *         0
 *     )
 * );
 *</code>
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) {

	zend_long index, ZEPHIR_LAST_CALL_STATUS;
	zval *model, model_sub, *index_param = NULL, source, schema, key, _0, _1, _2, _3, _4, _5;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&model_sub);
	ZVAL_UNDEF(&source);
	ZVAL_UNDEF(&schema);
	ZVAL_UNDEF(&key);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_2);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_5);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &model, &index_param);

	index = zephir_get_intval(index_param);


	ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&_0);
	zephir_get_class(&_0, model, 1 TSRMLS_CC);
	ZEPHIR_INIT_VAR(&key);
	ZEPHIR_CONCAT_VSVV(&key, &_0, "-", &schema, &source);
	zephir_read_property(&_1, this_ptr, SL("_metaData"), PH_NOISY_CC | PH_READONLY);
	zephir_array_fetch(&_2, &_1, &key, PH_READONLY, "phalcon/mvc/model/metadata.zep", 272 TSRMLS_CC);
	if (!(zephir_array_isset_long(&_2, index))) {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 5, model, &key, &source, &schema);
		zephir_check_call_status();
	}
	zephir_read_property(&_3, this_ptr, SL("_metaData"), PH_NOISY_CC | PH_READONLY);
	zephir_array_fetch(&_4, &_3, &key, PH_NOISY | PH_READONLY, "phalcon/mvc/model/metadata.zep", 276 TSRMLS_CC);
	zephir_array_fetch_long(&_5, &_4, index, PH_NOISY | PH_READONLY, "phalcon/mvc/model/metadata.zep", 276 TSRMLS_CC);
	RETURN_CTOR(&_5);

}
コード例 #8
0
ファイル: metadata.c プロジェクト: tianhendi/cphalcon
/**
 * Reads meta-data for certain model using a MODEL_* constant
 *
 *<code>
 *	print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
 *</code>
 *
 * @param Phalcon\Mvc\ModelInterface $model
 * @param int $index
 * @return array
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex){

	zval **model, **index, *table = NULL, *schema = NULL, *class_name;
	zval *key, *meta_data = NULL, *meta_data_index, *attributes;

	phalcon_fetch_params_ex(2, 0, &model, &index);

	PHALCON_VERIFY_INTERFACE_EX(*model, phalcon_mvc_modelinterface_ce, phalcon_mvc_model_exception_ce, 0);
	PHALCON_ENSURE_IS_LONG(index);

	PHALCON_MM_GROW();

	PHALCON_CALL_METHOD(&table, *model, "getsource");
	PHALCON_CALL_METHOD(&schema, *model, "getschema");
	
	PHALCON_INIT_VAR(class_name);
	phalcon_get_class(class_name, *model, 1 TSRMLS_CC);
	
	/** 
	 * Unique key for meta-data is created using class-name-schema-table
	 */
	PHALCON_INIT_VAR(key);
	PHALCON_CONCAT_VSVV(key, class_name, "-", schema, table);
	
	PHALCON_OBS_VAR(meta_data);
	phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY TSRMLS_CC);

	if (!phalcon_array_isset(meta_data, key)) {
		PHALCON_CALL_METHOD(NULL, this_ptr, "_initialize", *model, key, table, schema);
	
		PHALCON_OBS_NVAR(meta_data);
		phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY TSRMLS_CC);
	}

	PHALCON_OBS_VAR(meta_data_index);
	phalcon_array_fetch(&meta_data_index, meta_data, key, PH_NOISY);

	PHALCON_OBS_VAR(attributes);
	phalcon_array_fetch(&attributes, meta_data_index, *index, PH_NOISY);
	
	RETURN_CTOR(attributes);
}
コード例 #9
0
ファイル: resource.c プロジェクト: 11mariom/cphalcon
/**
 * Returns the complete location where the resource must be written
 *
 * @param string $basePath
 * @return string
 */
PHP_METHOD(Phalcon_Assets_Resource, getRealTargetPath){

	zval *base_path = NULL, *target_path = NULL, *local, *complete_path;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &base_path);
	
	if (!base_path) {
		PHALCON_INIT_VAR(base_path);
	}
	
	PHALCON_OBS_VAR(target_path);
	phalcon_read_property_this(&target_path, this_ptr, SL("_targetPath"), PH_NOISY_CC);
	if (PHALCON_IS_EMPTY(target_path)) {
		PHALCON_OBS_NVAR(target_path);
		phalcon_read_property_this(&target_path, this_ptr, SL("_path"), PH_NOISY_CC);
	}
	
	PHALCON_OBS_VAR(local);
	phalcon_read_property_this(&local, this_ptr, SL("_local"), PH_NOISY_CC);
	if (zend_is_true(local)) {
	
		/** 
		 * A base path for resources can be set in the assets manager
		 */
		PHALCON_INIT_VAR(complete_path);
		PHALCON_CONCAT_VV(complete_path, base_path, target_path);
	
		/** 
		 * Get the real template path, the target path can optionally don't exist
		 */
		if (phalcon_file_exists(complete_path TSRMLS_CC) == SUCCESS) {
			phalcon_call_func_p1(return_value, "realpath", complete_path);
			RETURN_MM();
		}
	
		RETURN_CTOR(complete_path);
	}
	
	RETURN_CCTOR(target_path);
}
コード例 #10
0
ファイル: db.c プロジェクト: logicode/cphalcon
/**
 * Dumps the complete result of a query into an array
 *
 * @param string $sqlQuery
 * @param int $fetchMode
 * @return array
 */
PHP_METHOD(Phalcon_Db, fetchAll){

	zval *sql_query = NULL, *fetch_mode = NULL, *results = NULL, *result = NULL;
	zval *row = NULL;
	zval *r0 = NULL;

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

	if (!fetch_mode) {
		PHALCON_ALLOC_ZVAL_MM(fetch_mode);
		ZVAL_LONG(fetch_mode, 2);
	}
	
	PHALCON_INIT_VAR(results);
	array_init(results);
	
	PHALCON_INIT_VAR(result);
	PHALCON_CALL_METHOD_PARAMS_1(result, this_ptr, "query", sql_query, PH_NO_CHECK);
	if (Z_TYPE_P(result) == IS_OBJECT) {
		PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", fetch_mode, PH_NO_CHECK);
		ph_cycle_start_0:
			
			PHALCON_INIT_VAR(r0);
			PHALCON_CALL_METHOD(r0, result, "fetcharray", PH_NO_CHECK);
			PHALCON_CPY_WRT(row, r0);
			if (!zend_is_true(row)) {
				goto ph_cycle_end_0;
			}
			phalcon_array_append(&results, row, PH_SEPARATE TSRMLS_CC);
			goto ph_cycle_start_0;
		ph_cycle_end_0:
		if(0){}
	}
	
	
	RETURN_CTOR(results);
}
コード例 #11
0
ファイル: text.c プロジェクト: croustibat/cphalcon
/**
 * Converts strings to camelize style
 *
 *<code>
 *	echo Phalcon\Text::camelize('coco_bongo'); //CocoBongo
 *</code>
 *
 * @param string $str
 * @return string
 */
PHP_METHOD(Phalcon_Text, camelize){

	zval *str = NULL, *space = NULL, *lower_str = NULL, *underscore = NULL, *no_underscore_str = NULL;
	zval *dash = NULL, *no_dash_str = NULL, *empty_str = NULL, *uc_string = NULL;
	zval *camelized = NULL;

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

	PHALCON_INIT_VAR(space);
	ZVAL_STRING(space, " ", 1);
	
	PHALCON_INIT_VAR(lower_str);
	PHALCON_CALL_FUNC_PARAMS_1(lower_str, "strtolower", str);
	
	PHALCON_INIT_VAR(underscore);
	ZVAL_STRING(underscore, "_", 1);
	
	PHALCON_INIT_VAR(no_underscore_str);
	phalcon_fast_str_replace(no_underscore_str, underscore, space, lower_str TSRMLS_CC);
	
	PHALCON_INIT_VAR(dash);
	ZVAL_STRING(dash, "-", 1);
	
	PHALCON_INIT_VAR(no_dash_str);
	phalcon_fast_str_replace(no_dash_str, dash, space, no_underscore_str TSRMLS_CC);
	
	PHALCON_INIT_VAR(empty_str);
	ZVAL_STRING(empty_str, "", 1);
	
	PHALCON_INIT_VAR(uc_string);
	PHALCON_CALL_FUNC_PARAMS_1(uc_string, "ucwords", no_dash_str);
	
	PHALCON_INIT_VAR(camelized);
	phalcon_fast_str_replace(camelized, space, empty_str, uc_string TSRMLS_CC);
	
	RETURN_CTOR(camelized);
}
コード例 #12
0
/**
 * Returns the query built
 *
 * @return Phalcon\Mvc\Model\Query
 */
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getQuery){

	zval *phql, *dependency_injector, *query, *bind_params;
	zval *bind_types;

	PHALCON_MM_GROW();

	/** 
	 * Process the PHQL
	 */
	PHALCON_INIT_VAR(phql);
	phalcon_call_method(phql, this_ptr, "getphql");
	
	PHALCON_OBS_VAR(dependency_injector);
	phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(query);
	object_init_ex(query, phalcon_mvc_model_query_ce);
	phalcon_call_method_p2_noret(query, "__construct", phql, dependency_injector);
	
	PHALCON_OBS_VAR(bind_params);
	phalcon_read_property_this(&bind_params, this_ptr, SL("_bindParams"), PH_NOISY_CC);
	
	/** 
	 * Set default bind params
	 */
	if (Z_TYPE_P(bind_params) == IS_ARRAY) { 
		phalcon_call_method_p1_noret(query, "setbindparams", bind_params);
	}
	
	PHALCON_OBS_VAR(bind_types);
	phalcon_read_property_this(&bind_types, this_ptr, SL("_bindTypes"), PH_NOISY_CC);
	
	/** 
	 * Set default bind params
	 */
	if (Z_TYPE_P(bind_types) == IS_ARRAY) { 
		phalcon_call_method_p1_noret(query, "setbindtypes", bind_types);
	}
	
	RETURN_CTOR(query);
}
コード例 #13
0
ファイル: form.zep.c プロジェクト: racztiborzoltan/cphalcon
/**
 * Returns a label for an element
 */
PHP_METHOD(Phalcon_Forms_Form, getLabel) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *name_param = NULL, *element = NULL, *label = NULL, *_0, *_1$$3;
	zval *name = NULL, *_2$$3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &name_param);

	if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) {
		zephir_get_strval(name, name_param);
	} else {
		ZEPHIR_INIT_VAR(name);
		ZVAL_EMPTY_STRING(name);
	}


	ZEPHIR_OBS_VAR(element);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC);
	if (!(zephir_array_isset_fetch(&element, _0, name, 0 TSRMLS_CC))) {
		ZEPHIR_INIT_VAR(_1$$3);
		object_init_ex(_1$$3, phalcon_forms_exception_ce);
		ZEPHIR_INIT_VAR(_2$$3);
		ZEPHIR_CONCAT_SVS(_2$$3, "Element with ID=", name, " is not part of the form");
		ZEPHIR_CALL_METHOD(NULL, _1$$3, "__construct", NULL, 9, _2$$3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1$$3, "phalcon/forms/form.zep", 507 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_CALL_METHOD(&label, element, "getlabel", NULL, 0);
	zephir_check_call_status();
	if (!(zephir_is_true(label))) {
		RETURN_CTOR(name);
	}
	RETURN_CCTOR(label);

}
コード例 #14
0
ファイル: profiler.c プロジェクト: Tigerlee1987/cphalcon
/**
 * Stops the active profile
 *
 * @return Phalcon\Db\Profiler
 */
PHP_METHOD(Phalcon_Db_Profiler, stopProfile){

	zval *micro, *final_time, *active_profile, *initial_time;
	zval *diference, *total_seconds, *new_total_seconds;
	zval *t0 = NULL;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(micro);
	ZVAL_BOOL(micro, 1);
	
	PHALCON_INIT_VAR(final_time);
	PHALCON_CALL_FUNC_PARAMS_1(final_time, "microtime", micro);
	
	PHALCON_INIT_VAR(active_profile);
	phalcon_read_property(&active_profile, this_ptr, SL("_activeProfile"), PH_NOISY_CC);
	PHALCON_CALL_METHOD_PARAMS_1_NORETURN(active_profile, "setfinaltime", final_time, PH_NO_CHECK);
	
	PHALCON_INIT_VAR(initial_time);
	PHALCON_CALL_METHOD(initial_time, active_profile, "getinitialtime", PH_NO_CHECK);
	
	PHALCON_INIT_VAR(diference);
	sub_function(diference, final_time, initial_time TSRMLS_CC);
	
	PHALCON_INIT_VAR(total_seconds);
	phalcon_read_property(&total_seconds, this_ptr, SL("_totalSeconds"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(new_total_seconds);
	phalcon_add_function(new_total_seconds, total_seconds, diference TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_totalSeconds"), new_total_seconds TSRMLS_CC);
	
	PHALCON_INIT_VAR(t0);
	phalcon_read_property(&t0, this_ptr, SL("_allProfiles"), PH_NOISY_CC);
	phalcon_array_append(&t0, active_profile, 0 TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_allProfiles"), t0 TSRMLS_CC);
	if (phalcon_method_exists_ex(this_ptr, SS("afterendprofile") TSRMLS_CC) == SUCCESS) {
		PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "afterendprofile", active_profile, PH_NO_CHECK);
	}
	
	
	RETURN_CTOR(this_ptr);
}
コード例 #15
0
ファイル: strings.zep.c プロジェクト: phalcon/zephir
PHP_METHOD(Test_Strings, strToHex) {

	unsigned char _1$$3;
	zend_long ZEPHIR_LAST_CALL_STATUS, i;
	zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL;
	zval *value_param = NULL, _0, _2$$3, _3$$3, _5$$3;
	zval value, ret;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&value);
	ZVAL_UNDEF(&ret);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_2$$3);
	ZVAL_UNDEF(&_3$$3);
	ZVAL_UNDEF(&_5$$3);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value_param);

	zephir_get_strval(&value, value_param);


	i = 0;
	ZEPHIR_INIT_VAR(&ret);
	ZVAL_STRING(&ret, "");
	while (1) {
		if (!(i < zephir_fast_strlen_ev(&value))) {
			break;
		}
		_1$$3 = ZEPHIR_STRING_OFFSET(&value, i);
		ZEPHIR_INIT_NVAR(&_2$$3);
		ZVAL_STRINGL(&_2$$3, &_1$$3, 1);
		ZEPHIR_CALL_FUNCTION(&_3$$3, "ord", &_4, 78, &_2$$3);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_5$$3, "dechex", &_6, 10, &_3$$3);
		zephir_check_call_status();
		zephir_concat_self(&ret, &_5$$3 TSRMLS_CC);
		i++;
	}
	RETURN_CTOR(&ret);

}
コード例 #16
0
ファイル: metadata.zep.c プロジェクト: dschissler/cphalcon
/**
 * Reads column-map information for certain model using a MODEL_* constant
 *
 *<code>
 * print_r(
 *     $metaData->readColumnMapIndex(
 *         new Robots(),
 *         MetaData::MODELS_REVERSE_COLUMN_MAP
 *     )
 * );
 *</code>
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) {

	zend_long index, ZEPHIR_LAST_CALL_STATUS;
	zval *model, model_sub, *index_param = NULL, keyName, columnMapModel, map, _0, _1$$4, _2$$4, _3$$4;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&model_sub);
	ZVAL_UNDEF(&keyName);
	ZVAL_UNDEF(&columnMapModel);
	ZVAL_UNDEF(&map);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_3$$4);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &model, &index_param);

	index = zephir_get_intval(index_param);


	if (!(ZEPHIR_GLOBAL(orm).column_renaming)) {
		RETURN_MM_NULL();
	}
	ZEPHIR_INIT_VAR(&keyName);
	zephir_get_class(&keyName, model, 1 TSRMLS_CC);
	ZEPHIR_OBS_VAR(&columnMapModel);
	zephir_read_property(&_0, this_ptr, SL("_columnMap"), PH_NOISY_CC | PH_READONLY);
	if (!(zephir_array_isset_fetch(&columnMapModel, &_0, &keyName, 0 TSRMLS_CC))) {
		ZVAL_NULL(&_1$$4);
		ZVAL_NULL(&_2$$4);
		ZVAL_NULL(&_3$$4);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 5, model, &_1$$4, &_2$$4, &_3$$4);
		zephir_check_call_status();
		zephir_read_property(&_1$$4, this_ptr, SL("_columnMap"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_OBS_NVAR(&columnMapModel);
		zephir_array_fetch(&columnMapModel, &_1$$4, &keyName, PH_NOISY, "phalcon/mvc/model/metadata.zep", 369 TSRMLS_CC);
	}
	zephir_array_isset_long_fetch(&map, &columnMapModel, index, 1 TSRMLS_CC);
	RETURN_CTOR(&map);

}
コード例 #17
0
ファイル: gettext.c プロジェクト: 9466/cphalcon
/**
 * Returns the translation related to the given key
 *
 * @param string $index
 * @param array $placeholders
 * @param string $domain
 * @return string
 */
PHP_METHOD(Phalcon_Translate_Adapter_Gettext, query){

	zval *index, *placeholders = NULL, *domain = NULL;
	zval *translation, *key = NULL, *value = NULL, *key_placeholder = NULL, *replaced = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;
	char *msgstr;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &index, &placeholders, &domain);
	
	if (!domain) {
		msgstr = gettext(Z_STRVAL_P(index));
	} else {
		msgstr = dgettext(Z_STRVAL_P(domain), Z_STRVAL_P(index));
	}

	PHALCON_INIT_VAR(translation);
	ZVAL_STRING(translation, msgstr, 1);

	if (placeholders && Z_TYPE_P(placeholders) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(placeholders))) {
		phalcon_is_iterable(placeholders, &ah0, &hp0, 0, 0);
		while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
			PHALCON_GET_HKEY(key, ah0, hp0);
			PHALCON_GET_HVALUE(value);

			PHALCON_INIT_NVAR(key_placeholder);
			PHALCON_CONCAT_SVS(key_placeholder, "%", key, "%");

			PHALCON_INIT_NVAR(replaced);
			phalcon_fast_str_replace(replaced, key_placeholder, value, translation);

			PHALCON_CPY_WRT(translation, replaced);

			zend_hash_move_forward_ex(ah0, &hp0);
		}
	}

	RETURN_CTOR(translation);
}
コード例 #18
0
/**
 * @param string id
 */
PHP_METHOD(Dgafka_BookStore_Application_InMemory_Repository_Command_BookRepository, findById) {

	zval *id_param = NULL, *_0, *_1, *_2;
	zval *id = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &id_param);

	zephir_get_strval(id, id_param);


	_0 = zephir_fetch_static_property_ce(dgafka_bookstore_application_inmemory_repository_command_bookrepository_ce, SL("books") TSRMLS_CC);
	if (!(zephir_array_key_exists(_0, id TSRMLS_CC))) {
		RETURN_MM_NULL();
	}
	_1 = zephir_fetch_static_property_ce(dgafka_bookstore_application_inmemory_repository_command_bookrepository_ce, SL("books") TSRMLS_CC);
	zephir_array_fetch(&_2, _1, id, PH_NOISY | PH_READONLY, "dgafka/bookStore/application/inMemory/repository/command/bookRepository.zep", 44 TSRMLS_CC);
	RETURN_CTOR(_2);

}
コード例 #19
0
/**
 * {@inheritdoc}
 */
PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, read) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *sessionId_param = NULL, *_0, *_1 = NULL, *_2;
	zval *sessionId = NULL, *_3 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &sessionId_param);

	zephir_get_strval(sessionId, sessionId_param);


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC);
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_1, _0, "get", NULL, 0, sessionId, _2);
	zephir_check_call_status();
	zephir_get_strval(_3, _1);
	RETURN_CTOR(_3);

}
コード例 #20
0
ファイル: dump.c プロジェクト: Myleft/cphalcon
/**
 * Get style for type
 */
PHP_METHOD(Phalcon_Debug_Dump, getStyle){

	zval *type, *styles, *style;

	PHALCON_MM_GROW();

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

	styles  = phalcon_fetch_nproperty_this(this_ptr, SL("_styles"), PH_NOISY TSRMLS_CC);

	if (phalcon_array_isset(styles, type)) {
		PHALCON_OBS_VAR(style);
		phalcon_array_fetch(&style, styles, type, PH_NOISY);
	} else {
		PHALCON_INIT_VAR(style);
		ZVAL_STRING(style, "color:gray", 1);
	}

	RETURN_CTOR(style);
}
コード例 #21
0
/**
 * Serializing a resultset will dump all related rows into a big array
 *
 * @return string
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize){

	zval *records, *cache, *column_types, *hydrate_mode;
	zval *data, *serialized;

	PHALCON_MM_GROW();

	/** 
	 * Obtain the records as an array
	 */
	PHALCON_INIT_VAR(records);
	phalcon_call_method(records, this_ptr, "toarray");
	
	PHALCON_OBS_VAR(cache);
	phalcon_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC);
	
	PHALCON_OBS_VAR(column_types);
	phalcon_read_property_this(&column_types, this_ptr, SL("_columnTypes"), PH_NOISY_CC);
	
	PHALCON_OBS_VAR(hydrate_mode);
	phalcon_read_property_this(&hydrate_mode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(data);
	array_init_size(data, 4);
	phalcon_array_update_string(&data, SL("cache"), &cache, PH_COPY | PH_SEPARATE);
	phalcon_array_update_string(&data, SL("rows"), &records, PH_COPY | PH_SEPARATE);
	phalcon_array_update_string(&data, SL("columnTypes"), &column_types, PH_COPY | PH_SEPARATE);
	phalcon_array_update_string(&data, SL("hydrateMode"), &hydrate_mode, PH_COPY | PH_SEPARATE);
	
	PHALCON_INIT_VAR(serialized);
	phalcon_serialize(serialized, &data TSRMLS_CC);
	
	/** 
	 * Avoid return bad serialized data
	 */
	if (Z_TYPE_P(serialized) != IS_STRING) {
		RETURN_MM_NULL();
	}
	
	RETURN_CTOR(serialized);
}
コード例 #22
0
ファイル: postgresql.c プロジェクト: rcpsec/cphalcon
/**
 * Generates SQL to add an index to a table
 *
 * @param string $tableName
 * @param string $schemaName
 * @param Phalcon_Db_Index $index
 * @return string
 */
PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addIndex){

	zval *table_name = NULL, *schema_name = NULL, *index = NULL, *sql = NULL;
	zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &table_name, &schema_name, &index) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (Z_TYPE_P(index) != IS_OBJECT) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Index parameter must be an instance of Phalcon_Db_Index");
		return;
	}
	if (zend_is_true(schema_name)) {
		PHALCON_ALLOC_ZVAL_MM(r0);
		PHALCON_CONCAT_SVSVS(r0, "ALTER TABLE ", schema_name, ".", table_name, " ADD INDEX ");
		PHALCON_CPY_WRT(sql, r0);
	} else {
		PHALCON_ALLOC_ZVAL_MM(r1);
		PHALCON_CONCAT_SVS(r1, "ALTER TABLE ", table_name, " ADD INDEX ");
		PHALCON_CPY_WRT(sql, r1);
	}
	
	PHALCON_ALLOC_ZVAL_MM(r2);
	
	PHALCON_ALLOC_ZVAL_MM(r3);
	PHALCON_CALL_METHOD(r3, index, "getname", PHALCON_NO_CHECK);
	
	PHALCON_ALLOC_ZVAL_MM(r4);
	
	PHALCON_ALLOC_ZVAL_MM(r5);
	PHALCON_CALL_METHOD(r5, index, "getcolumns", PHALCON_NO_CHECK);
	PHALCON_CALL_SELF_PARAMS_1(r4, this_ptr, "getcolumnlist", r5);
	PHALCON_CONCAT_SVSVS(r2, "\"", r3, "\" (", r4, ")");
	phalcon_concat_self(&sql, r2 TSRMLS_CC);
	
	RETURN_CTOR(sql);
}
コード例 #23
0
ファイル: session.zep.c プロジェクト: swordkee/yaftoz
/**
 * Retrieve singleton instance
 *
 * @return Yaf_Session
 */
PHP_METHOD(Yaf_Session, getInstance) {

    int ZEPHIR_LAST_CALL_STATUS;
    zval *_0, *_1, *_2;

    ZEPHIR_MM_GROW();

    _0 = zephir_fetch_static_property_ce(yaf_session_ce, SL("_instance") TSRMLS_CC);
    if (Z_TYPE_P(_0) == IS_NULL) {
        ZEPHIR_INIT_VAR(_1);
        object_init_ex(_1, yaf_session_ce);
        ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL);
        zephir_check_call_status();
        zephir_update_static_property_ce(yaf_session_ce, SL("_instance"), &_1 TSRMLS_CC);
        ZEPHIR_CALL_SELF(NULL, "start", NULL);
        zephir_check_call_status();
    }
    _2 = zephir_fetch_static_property_ce(yaf_session_ce, SL("_instance") TSRMLS_CC);
    RETURN_CTOR(_2);

}
コード例 #24
0
ファイル: flash.c プロジェクト: fatihzkaratana/cphalcon
/**
 * Shows a HTML warning message
 *
 * @param string $message
 * @param string $classes
 * @return string
 */
PHP_METHOD(Phalcon_Flash, warning){

	zval *message = NULL, *classes = NULL;
	zval *r0 = NULL;

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

	if (!classes) {
		PHALCON_ALLOC_ZVAL_MM(classes);
		ZVAL_STRING(classes, "warningMessage", 1);
	}
	
	PHALCON_ALLOC_ZVAL_MM(r0);
	PHALCON_CALL_SELF_PARAMS_2(r0, this_ptr, "_showmessage", message, classes);
	RETURN_CTOR(r0);
}
コード例 #25
0
ファイル: manager.c プロジェクト: 100851766/cphalcon
/**
 * Returns a custom events manager related to a model
 *
 * @param Phalcon\Mvc\CollectionInterface $model
 * @return Phalcon\Events\ManagerInterface
 */
PHP_METHOD(Phalcon_Mvc_Collection_Manager, getCustomEventsManager){

	zval *model, *custom_events_manager, *class_name;
	zval *events_manager;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &model);
	
	custom_events_manager = phalcon_fetch_nproperty_this(this_ptr, SL("_customEventsManager"), PH_NOISY TSRMLS_CC);
	if (Z_TYPE_P(custom_events_manager) == IS_ARRAY) { 
	
		PHALCON_INIT_VAR(class_name);
		phalcon_get_class(class_name, model, 1 TSRMLS_CC);
		if (phalcon_array_isset_fetch(&events_manager, custom_events_manager, class_name)) {
			RETURN_CTOR(events_manager);
		}
	}
	
	RETURN_MM_NULL();
}
コード例 #26
0
ファイル: nativearray.c プロジェクト: RandomStuffs22/zephir
PHP_METHOD(Test_NativeArray, testArrayAccess1) {

	zval *a, *b, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	zephir_array_fetch_long(&b, a, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	RETURN_CTOR(b);

}
コード例 #27
0
ファイル: mysql.c プロジェクト: meibk/cphalcon
/**
 * Generates SQL to delete primary key from a table
 *
 * @param string $tableName
 * @param string $schemaName
 * @return string
 */
PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropPrimaryKey){

	zval *table_name = NULL, *schema_name = NULL, *sql = NULL;

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

	if (zend_is_true(schema_name)) {
		PHALCON_INIT_VAR(sql);
		PHALCON_CONCAT_SVSVS(sql, "ALTER TABLE `", schema_name, "`.`", table_name, "` DROP PRIMARY KEY");
	} else {
		PHALCON_INIT_VAR(sql);
		PHALCON_CONCAT_SVS(sql, "ALTER TABLE `", table_name, "` DROP PRIMARY KEY");
	}
	
	RETURN_CTOR(sql);
}
コード例 #28
0
ファイル: metadata.c プロジェクト: 100851766/cphalcon
/**
 * Returns the column map if any
 *
 *<code>
 *	print_r($metaData->getColumnMap(new Robots()));
 *</code>
 *
 * @param Phalcon\Mvc\ModelInterface $model
 * @return array
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMap){

	zval *model, *index, *data = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &model);
	
	PHALCON_INIT_VAR(index);
	ZVAL_LONG(index, 0);
	
	PHALCON_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", model, index);
	if (Z_TYPE_P(data) != IS_NULL) {
		if (Z_TYPE_P(data) != IS_ARRAY) { 
			PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt");
			return;
		}
	}
	
	RETURN_CTOR(data);
}
コード例 #29
0
ファイル: request.c プロジェクト: meibk/cphalcon
/**
 * Gets HTTP schema (http/https)
 *
 * @return string
 */
PHP_METHOD(Phalcon_Http_Request, getScheme){

	zval *https_header = NULL, *https = NULL, *scheme = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(https_header);
	ZVAL_STRING(https_header, "HTTP_HTTPS", 1);
	
	PHALCON_INIT_VAR(https);
	PHALCON_CALL_METHOD_PARAMS_1(https, this_ptr, "getserver", https_header, PH_NO_CHECK);
	if (PHALCON_COMPARE_STRING(https, "on")) {
		PHALCON_INIT_VAR(scheme);
		ZVAL_STRING(scheme, "https", 1);
	} else {
		PHALCON_INIT_VAR(scheme);
		ZVAL_STRING(scheme, "http", 1);
	}
	
	
	RETURN_CTOR(scheme);
}
コード例 #30
0
ファイル: nativearray.zep.c プロジェクト: phalcon/zephir
PHP_METHOD(Test_NativeArray, issue743b) {

	zval *current_param = NULL, _0;
	zval current;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&current);
	ZVAL_UNDEF(&_0);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &current_param);

	zephir_get_arrval(&current, current_param);


	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "ok");
	zephir_array_update_multi(&current, &_0 TSRMLS_CC, SL("sl"), 3, SL("str"), 42);
	RETURN_CTOR(&current);

}