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

C++ PHALCON_SEPARATE_PARAM函数代码示例

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

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



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

示例1: PHP_METHOD

/**
 * Blur image
 *
 * @param int $radius Blur radius
 * @return Phalcon\Image\Adapter
 */
PHP_METHOD(Phalcon_Image_Adapter, blur) {

    zval *radius = NULL;
    long r;

    PHALCON_MM_GROW();

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

    if (!radius) {
        PHALCON_INIT_VAR(radius);
        ZVAL_LONG(radius, 1);
    } else if (Z_TYPE_P(radius) != IS_LONG) {
        PHALCON_SEPARATE_PARAM(radius);

        PHALCON_INIT_NVAR(radius);
        ZVAL_LONG(radius, 1);
    } else {
        r = phalcon_get_intval(radius);
        if (r < 1) {
            PHALCON_SEPARATE_PARAM(radius);
            PHALCON_INIT_NVAR(radius);
            ZVAL_LONG(radius, 1);
        } else if (r > 100) {
            PHALCON_SEPARATE_PARAM(radius);
            PHALCON_INIT_NVAR(radius);
            ZVAL_LONG(radius, 100);
        }
    }

    PHALCON_CALL_METHOD(NULL, this_ptr, "_blur", radius);

    RETURN_THIS();
}
开发者ID:9466,项目名称:cphalcon,代码行数:40,代码来源:adapter.c


示例2: PHP_METHOD

/**
 * Phalcon_Model_MetaData_Session constructor
 *
 * @param Phalcon_Config|stdClass $options
 */
PHP_METHOD(Phalcon_Model_MetaData_Session, __construct){

	zval *options = NULL, *adapter_options = NULL;
	zval *t0 = NULL;
	int eval_int;

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

	PHALCON_SEPARATE_PARAM(options);
	
	if (Z_TYPE_P(options) == IS_ARRAY) { 
		PHALCON_SEPARATE_PARAM(options);
		convert_to_array(options);
		PHALCON_CPY_WRT(adapter_options, options);
	} else {
		PHALCON_CPY_WRT(adapter_options, options);
	}
	eval_int = phalcon_isset_property(adapter_options, "suffix", strlen("suffix") TSRMLS_CC);
	if (eval_int) {
		PHALCON_ALLOC_ZVAL_MM(t0);
		phalcon_read_property(&t0, adapter_options, "suffix", sizeof("suffix")-1, PHALCON_NOISY TSRMLS_CC);
		phalcon_update_property_zval(this_ptr, "_suffix", strlen("_suffix"), t0 TSRMLS_CC);
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:andresgutierrez,项目名称:cphalcon,代码行数:36,代码来源:session.c


示例3: PHP_METHOD

/**
 * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch()
 *
 *<code>
 *	//Return array with integer indexes
 *	$result->setFetchMode(Phalcon\Db::FETCH_NUM);
 *
 *	//Return associative array without integer indexes
 *	$result->setFetchMode(Phalcon\Db::FETCH_ASSOC);
 *
 *	//Return associative array together with integer indexes
 *	$result->setFetchMode(Phalcon\Db::FETCH_BOTH);
 *
 *	//Return an object
 *	$result->setFetchMode(Phalcon\Db::FETCH_OBJ);
 *</code>
 *
 * @param int $fetchMode
 */
PHP_METHOD(Phalcon_Db_Result_Pdo, setFetchMode){

	zval *fetch_mode, *fetch_arg1 = NULL, *fetch_arg2 = NULL;
	zval *pdo_statement;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &fetch_mode, &fetch_arg1, &fetch_arg2);

	PHALCON_SEPARATE_PARAM(fetch_mode);
	if (Z_TYPE_P(fetch_mode) != IS_LONG) {
		convert_to_long(fetch_mode);
	}

	pdo_statement = phalcon_read_property(getThis(), SL("_pdoStatement"), PH_NOISY);

	if (Z_LVAL_P(fetch_mode) != 0) {
		if (fetch_arg1 && fetch_arg2) {
			PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg1, fetch_arg2);
		} else if (fetch_arg1) {
			PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg1);
		} else if (fetch_arg2) {
			PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg2);
		} else {
			PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode);
		}
		
		phalcon_update_property_long(getThis(), SL("_fetchMode"), Z_LVAL_P(fetch_mode));
	}

	RETURN_MM_NULL();
}
开发者ID:Myleft,项目名称:cphalcon7,代码行数:51,代码来源:pdo.c


示例4: PHP_METHOD

/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection.
 *
 * @param array $descriptor
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, connect){

	zval *descriptor = NULL, *dbname;

	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 (!zend_is_true(descriptor)) {
		PHALCON_OBS_NVAR(descriptor);
		phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC);
	}
	if (!phalcon_array_isset_string(descriptor, SS("dbname"))) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "dbname must be specified");
		return;
	} else {
		PHALCON_OBS_VAR(dbname);
		phalcon_array_fetch_string(&dbname, descriptor, SL("dbname"), PH_NOISY_CC);
		phalcon_array_update_string(&descriptor, SL("dsn"), &dbname, PH_COPY | PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon\\Db\\Adapter\\Pdo\\Sqlite", "connect", descriptor);
	
	PHALCON_MM_RESTORE();
}
开发者ID:Gildus,项目名称:cphalcon,代码行数:40,代码来源:sqlite.c


示例5: PHP_METHOD

/**
 * Creates a password hash using bcrypt with a pseudo random salt
 *
 * @param string $password
 * @param int $workFactor
 * @return string
 */
PHP_METHOD(Phalcon_Security, hash){

	zval *password, *work_factor = NULL, *format, *factor;
	zval *salt_bytes, *salt;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &password, &work_factor);
	
	if (!work_factor) {
		PHALCON_INIT_VAR(work_factor);
	} else {
		PHALCON_SEPARATE_PARAM(work_factor);
	}
	
	if (Z_TYPE_P(work_factor) == IS_NULL) {
		PHALCON_OBS_NVAR(work_factor);
		phalcon_read_property_this(&work_factor, this_ptr, SL("_workFactor"), PH_NOISY_CC);
	}
	
	PHALCON_INIT_VAR(format);
	ZVAL_STRING(format, "%02s", 1);
	
	PHALCON_INIT_VAR(factor);
	phalcon_call_func_p2(factor, "sprintf", format, work_factor);
	
	PHALCON_INIT_VAR(salt_bytes);
	phalcon_call_method(salt_bytes, this_ptr, "getsaltbytes");
	
	PHALCON_INIT_VAR(salt);
	PHALCON_CONCAT_SVSV(salt, "$2a$", factor, "$", salt_bytes);
	phalcon_call_func_p2(return_value, "crypt", password, salt);
	RETURN_MM();
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:41,代码来源:security.c


示例6: PHP_METHOD

/**
 * Phalcon\Cache\Backend\Xcache constructor
 *
 * @param Phalcon\Cache\FrontendInterface $frontend
 * @param array $options
 */
PHP_METHOD(Phalcon_Cache_Backend_Xcache, __construct){

	zval *frontend, *options = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &frontend, &options);
	
	if (!options) {
		PHALCON_INIT_VAR(options);
	} else {
		PHALCON_SEPARATE_PARAM(options);
	}
	
	if (Z_TYPE_P(options) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(options);
		array_init(options);
	}

	if (!phalcon_array_isset_str(options, SL("statsKey"))) {
		phalcon_array_update_str_str(options, SL("statsKey"), SL("_PHCX"), PH_COPY);
	}
	
	PHALCON_CALL_PARENT(NULL, phalcon_cache_backend_xcache_ce, getThis(), "__construct", frontend, options);
	
	PHALCON_MM_RESTORE();
}
开发者ID:Myleft,项目名称:cphalcon7,代码行数:33,代码来源:xcache.c


示例7: PHP_METHOD

/**
 * Phalcon\Cache\Backend\Xcache constructor
 *
 * @param Phalcon\Cache\FrontendInterface $frontend
 * @param array $options
 */
PHP_METHOD(Phalcon_Cache_Backend_Xcache, __construct){

	zval *frontend, *options = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &frontend, &options);
	
	if (!options) {
		PHALCON_INIT_VAR(options);
	} else {
		PHALCON_SEPARATE_PARAM(options);
	}
	
	if (Z_TYPE_P(options) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(options);
		array_init(options);
	}
	if (!phalcon_array_isset_string(options, SS("statsKey"))) {
		phalcon_array_update_string_string(&options, SL("statsKey"), SL("_PHCX"), PH_SEPARATE TSRMLS_CC);
	}
	
	PHALCON_CALL_PARENT_PARAMS_2_NORETURN(this_ptr, "Phalcon\\Cache\\Backend\\Xcache", "__construct", frontend, options);
	
	PHALCON_MM_RESTORE();
}
开发者ID:RSivakov,项目名称:cphalcon,代码行数:32,代码来源:xcache.c


示例8: PHP_METHOD

/**
 * Constructor for Phalcon_Db_Adapter_Mysql. This method does not should to be called directly. Use Phalcon_Db::factory instead
 *
 * @param stdClass $descriptor
 */
PHP_METHOD(Phalcon_Db_Adapter_Mysql, __construct){

	zval *descriptor = NULL;
	zval *t0 = NULL;

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

	if (!descriptor) {
		PHALCON_INIT_VAR(descriptor);
		ZVAL_NULL(descriptor);
	} else {
		PHALCON_SEPARATE_PARAM(descriptor);
	}
	
	if (!zend_is_true(descriptor)) {
		PHALCON_ALLOC_ZVAL_MM(t0);
		phalcon_read_property(&t0, this_ptr, SL("_descriptor"), PHALCON_NOISY TSRMLS_CC);
		PHALCON_CPY_WRT(descriptor, t0);
	}
	PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "connect", descriptor, PHALCON_NO_CHECK);
	
	PHALCON_MM_RESTORE();
}
开发者ID:rcpsec,项目名称:cphalcon,代码行数:33,代码来源:mysql.c


示例9: PHP_METHOD

/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &css_classes);
	
	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_this(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:31,代码来源:flash.c


示例10: PHP_METHOD

/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

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

	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_zval(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:bicouy0,项目名称:cphalcon,代码行数:33,代码来源:flash.c


示例11: PHP_METHOD

/**
 * Parses a raw doc block returning the annotations found
 *
 * @param string $docBlock
 * @param string $file
 * @param int $line
 * @return array
 */
PHP_METHOD(Phalcon_Annotations_Reader, parseDocBlock){

	zval *doc_block, *file = NULL, *line = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &doc_block, &file, &line);
	
	if (!file) {
		PHALCON_INIT_VAR(file);
	} else {
		PHALCON_SEPARATE_PARAM(file);
	}
	
	if (!line) {
		PHALCON_INIT_VAR(line);
	}
	
	if (Z_TYPE_P(file) != IS_STRING) {
		PHALCON_INIT_NVAR(file);
		ZVAL_STRING(file, "eval code", 1);
	}
	if (phannot_parse_annotations(return_value, doc_block, file, line TSRMLS_CC) == FAILURE) {
		return;
	}
	RETURN_MM();
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:35,代码来源:reader.c


示例12: PHP_METHOD

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

	zval *arguments = NULL, *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(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_SEPARATE);
	}
	
	/** 
	 * 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_SEPARATE);
	}
	
	/** 
	 * 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_SEPARATE);
	}
	
	phalcon_update_property_this(this_ptr, SL("_module"), module_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:CreativeOutbreak,项目名称:cphalcon,代码行数:65,代码来源:router.c


示例13: PHP_METHOD

/**
 * Phalcon\Mvc\Model\Transaction\Manager constructor
 *
 * @param Phalcon\DiInterface $dependencyInjector
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, __construct){

	zval *dependency_injector = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &dependency_injector);
	
	if (!dependency_injector) {
		PHALCON_INIT_VAR(dependency_injector);
	} else {
		PHALCON_SEPARATE_PARAM(dependency_injector);
	}
	
	if (zend_is_true(dependency_injector)) {
		phalcon_update_property_this(this_ptr, SL("_dependencyInjector"), dependency_injector TSRMLS_CC);
	} else {
		PHALCON_INIT_NVAR(dependency_injector);
		PHALCON_CALL_STATIC(dependency_injector, "phalcon\\di", "getdefault");
		phalcon_update_property_this(this_ptr, SL("_dependencyInjector"), dependency_injector TSRMLS_CC);
	}
	if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM");
		return;
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:33,代码来源:manager.c


示例14: test_phalcon_separate_param

void test_phalcon_separate_param(void)
{
	startup_php(__func__);
	zend_first_try {
		zval* x;
		zval* orig;

		PHALCON_MM_GROW();
			MAKE_STD_ZVAL(x);
			ZVAL_LONG(x, 0xB61964F6l);
			Z_ADDREF_P(x);
			Z_ADDREF_P(x);
			Z_ADDREF_P(x);
			orig = x;

			CU_ASSERT_EQUAL(Z_REFCOUNT_P(x), 4);
			CU_ASSERT_EQUAL(Z_ISREF_P(x), 0);

			PHALCON_SEPARATE_PARAM(x);

			CU_ASSERT_EQUAL(Z_REFCOUNT_P(x), 1);
			CU_ASSERT_EQUAL(Z_ISREF_P(x), 0);
			CU_ASSERT_PTR_NOT_EQUAL(x, orig);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 4);
			CU_ASSERT_EQUAL(Z_ISREF_P(orig), 0);

			CU_ASSERT_EQUAL(Z_TYPE_P(x), IS_LONG);
			CU_ASSERT_EQUAL(Z_LVAL_P(x), 0xB61964F6l);

			CU_ASSERT_EQUAL(Z_TYPE_P(x), Z_TYPE_P(orig));
			CU_ASSERT_EQUAL(Z_LVAL_P(x), Z_LVAL_P(orig));

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 3);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 2);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 1);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
		PHALCON_MM_RESTORE();
	}
	zend_catch {
		CU_ASSERT(0);
	}
	zend_end_try();

	shutdown_php();
	CU_ASSERT_EQUAL(leaks, 0);
}
开发者ID:ubraz,项目名称:phalcon-kernel-test,代码行数:59,代码来源:test_memory.c


示例15: PHP_METHOD

/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection.
 *
 * Support set search_path after connectted if schema is specified in config.
 *
 * @param array $descriptor
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, connect){

	zval *descriptor = NULL, *schema = NULL, *sql, *password;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &descriptor);
	
	if (!descriptor) {
		PHALCON_INIT_VAR(descriptor);
	} else {
		PHALCON_SEPARATE_PARAM(descriptor);
	}
	
	if (!zend_is_true(descriptor)) {
		PHALCON_OBS_NVAR(descriptor);
		phalcon_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY TSRMLS_CC);
	}
	
	if (phalcon_array_isset_string(descriptor, SS("schema"))) {
		PHALCON_OBS_VAR(schema);
		phalcon_array_fetch_string(&schema, descriptor, SL("schema"), PH_NOISY);
		phalcon_array_unset_string(&descriptor, SS("schema"), PH_COPY);

		phalcon_update_property_this(this_ptr, SL("_schema"), schema TSRMLS_CC);
	}
	else {
		PHALCON_INIT_VAR(schema);
	}

	if (phalcon_array_isset_string_fetch(&password, descriptor, SS("password"))) {
		/* There is a bug in pdo_pgsql driver when the password is empty,
		 * the driver tries to access invalid memory:
		 *
		 * if (dbh->password[0] != '\'' && dbh->password[strlen(dbh->password) - 1] != '\'')
		 *
		 * To avoid this we set the password to null
		 */
		if (Z_TYPE_P(password) == IS_STRING && Z_STRLEN_P(password) == 0) {
			phalcon_array_update_string(&descriptor, SL("password"), PHALCON_GLOBAL(z_null), PH_COPY);
		}
	}

	
	PHALCON_CALL_PARENT(NULL, phalcon_db_adapter_pdo_postgresql_ce, this_ptr, "connect", descriptor);
	
	/** 
	 * Execute the search path in the after connect
	 */
	if (Z_TYPE_P(schema) == IS_STRING) {
		PHALCON_INIT_VAR(sql);
		PHALCON_CONCAT_SVS(sql, "SET search_path TO '", schema, "'");
		PHALCON_CALL_METHOD(NULL, this_ptr, "execute", sql);
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:banketree,项目名称:cphalcon,代码行数:66,代码来源:postgresql.c


示例16: PHP_METHOD

/**
 * Applies the internal format to the message
 *
 * @param  string $message
 * @param  int $type
 * @param  int $time
 * @return string
 */
PHP_METHOD(Phalcon_Logger_Adapter_File, _applyFormat){

	zval *message = NULL, *type = NULL, *time = NULL, *format = NULL, *date_format = NULL;
	zval *date = NULL, *new_format = NULL, *type_string = NULL;
	zval *c0 = NULL, *c1 = NULL, *c2 = NULL;

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

	if (!time) {
		PHALCON_ALLOC_ZVAL_MM(time);
		ZVAL_LONG(time, 0);
	} else {
		PHALCON_SEPARATE_PARAM(time);
	}
	
	if (!zend_is_true(time)) {
		PHALCON_INIT_VAR(time);
		PHALCON_CALL_FUNC(time, "time");
	}
	
	PHALCON_INIT_VAR(format);
	phalcon_read_property(&format, this_ptr, SL("_format"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(date_format);
	phalcon_read_property(&date_format, this_ptr, SL("_dateFormat"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(date);
	PHALCON_CALL_FUNC_PARAMS_2(date, "date", date_format, time);
	
	PHALCON_INIT_VAR(c0);
	ZVAL_STRING(c0, "%date%", 1);
	
	PHALCON_INIT_VAR(new_format);
	phalcon_fast_str_replace(new_format, c0, date, format TSRMLS_CC);
	
	PHALCON_INIT_VAR(type_string);
	PHALCON_CALL_METHOD_PARAMS_1(type_string, this_ptr, "gettypestring", type, PH_NO_CHECK);
	
	PHALCON_INIT_VAR(c1);
	ZVAL_STRING(c1, "%type%", 1);
	
	PHALCON_INIT_VAR(format);
	phalcon_fast_str_replace(format, c1, type_string, new_format TSRMLS_CC);
	
	PHALCON_INIT_VAR(c2);
	ZVAL_STRING(c2, "%message%", 1);
	
	PHALCON_INIT_VAR(new_format);
	phalcon_fast_str_replace(new_format, c2, message, format TSRMLS_CC);
	
	RETURN_CTOR(new_format);
}
开发者ID:awakmu,项目名称:cphalcon,代码行数:65,代码来源:file.c


示例17: PHP_METHOD

/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection.
 *
 * Support set search_path after connectted if schema is specified in config.
 *
 * @param array $descriptor
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, connect) {

    zval *descriptor = NULL, *schema = NULL, *sql = NULL;
    int eval_int;

    PHALCON_MM_GROW();

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

    if (!descriptor) {
        PHALCON_ALLOC_ZVAL_MM(descriptor);
        ZVAL_NULL(descriptor);
    } else {
        PHALCON_SEPARATE_PARAM(descriptor);
    }

    if (!zend_is_true(descriptor)) {
        PHALCON_INIT_VAR(descriptor);
        phalcon_read_property(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC);
    }

    PHALCON_INIT_VAR(schema);
    ZVAL_NULL(schema);
    eval_int = phalcon_array_isset_string(descriptor, SS("schema"));
    if (eval_int) {
        PHALCON_INIT_VAR(schema);
        phalcon_array_fetch_string(&schema, descriptor, SL("schema"), PH_NOISY_CC);
        PHALCON_SEPARATE_PARAM(descriptor);
        phalcon_array_unset_string(descriptor, SS("schema"));
    }

    PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon\\Db\\Adapter\\Pdo\\Postgresql", "connect", descriptor);
    if (Z_TYPE_P(schema) == IS_STRING) {
        PHALCON_INIT_VAR(sql);
        PHALCON_CONCAT_SVS(sql, "SET search_path TO '", schema, "'");
        PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "execute", sql, PH_NO_CHECK);
    }

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


示例18: PHP_METHOD

/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection.
 *
 * @param array $descriptor
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, connect) {

    zval *descriptor = NULL, *startup, *value = NULL;
    HashTable *ah0;
    HashPosition hp0;
    zval **hd;

    PHALCON_MM_GROW();

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

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

    if (!zend_is_true(descriptor)) {
        PHALCON_OBS_NVAR(descriptor);
        phalcon_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY TSRMLS_CC);
    }

    /**
     * Connect
     */
    PHALCON_CALL_PARENT(NULL, phalcon_db_adapter_pdo_oracle_ce, this_ptr, "connect", descriptor);

    /**
     * Database session settings initiated with each HTTP request. Oracle behaviour
     * depends on particular NLS* parameter. Check if the developer has defined custom
     * startup or create one from scratch
     */
    if (phalcon_array_isset_string(descriptor, SS("startup"))) {

        PHALCON_OBS_VAR(startup);
        phalcon_array_fetch_string(&startup, descriptor, SL("startup"), PH_NOISY);
        if (Z_TYPE_P(startup) == IS_ARRAY) {

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

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

                PHALCON_GET_HVALUE(value);

                PHALCON_CALL_METHOD(NULL, this_ptr, "execute", value);

                zend_hash_move_forward_ex(ah0, &hp0);
            }

        }
    }

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


示例19: PHP_METHOD

/**
 * Appends a message to the validator
 *
 * @param string $message
 * @param string $field
 * @param string $type
 */
PHP_METHOD(Phalcon_Mvc_Model_Validator, appendMessage){

	zval *message = NULL, *field = NULL, *type = NULL, *class_name = NULL, *suffix = NULL;
	zval *empty_string = NULL, *model_message = NULL;
	zval *t0 = NULL;

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

	if (!field) {
		PHALCON_ALLOC_ZVAL_MM(field);
		ZVAL_NULL(field);
	}
	
	if (!type) {
		PHALCON_ALLOC_ZVAL_MM(type);
		ZVAL_NULL(type);
	} else {
		PHALCON_SEPARATE_PARAM(type);
	}
	
	if (!zend_is_true(type)) {
		PHALCON_INIT_VAR(class_name);
		phalcon_get_class(class_name, this_ptr TSRMLS_CC);
		
		PHALCON_INIT_VAR(suffix);
		ZVAL_STRING(suffix, "Validator", 1);
		
		PHALCON_INIT_VAR(empty_string);
		ZVAL_STRING(empty_string, "", 1);
		
		PHALCON_INIT_VAR(type);
		phalcon_fast_str_replace(type, suffix, empty_string, class_name TSRMLS_CC);
	}
	
	PHALCON_INIT_VAR(model_message);
	object_init_ex(model_message, phalcon_mvc_model_message_ce);
	PHALCON_CALL_METHOD_PARAMS_3_NORETURN(model_message, "__construct", message, field, type, PH_CHECK);
	
	PHALCON_ALLOC_ZVAL_MM(t0);
	phalcon_read_property(&t0, this_ptr, SL("_messages"), PH_NOISY_CC);
	phalcon_array_append(&t0, model_message, 0 TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_messages"), t0 TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
开发者ID:meibk,项目名称:cphalcon,代码行数:57,代码来源:validator.c


示例20: PHP_METHOD

/**
 * Moves internal resulset cursor to another position letting us to fetch a certain row
 *
 * @param int $number
 */
PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek) {

    zval *number = NULL, *n = NULL, *pdo_statement = NULL, *result = NULL;
    zval *r0 = NULL, *r1 = NULL;
    zval *t0 = NULL, *t1 = NULL;

    PHALCON_MM_GROW();

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

    PHALCON_SEPARATE_PARAM(number);

    PHALCON_INIT_VAR(t1);
    ZVAL_LONG(t1, 1);
    PHALCON_INIT_VAR(t0);
    ZVAL_LONG(t0, -1);
    PHALCON_ALLOC_ZVAL_MM(r0);
    mul_function(r0, t0, t1 TSRMLS_CC);
    PHALCON_CPY_WRT(n, r0);
    decrement_function(number);

    PHALCON_INIT_VAR(pdo_statement);
    phalcon_read_property(&pdo_statement, this_ptr, SL("_pdoStatement"), PH_NOISY_CC);
    PHALCON_CALL_METHOD_NORETURN(pdo_statement, "execute", PH_NO_CHECK);
ws_a5eb_0:

    PHALCON_INIT_VAR(r1);
    is_not_equal_function(r1, n, number TSRMLS_CC);
    if (!zend_is_true(r1)) {
        goto we_a5eb_0;
    }
    PHALCON_INIT_VAR(result);
    PHALCON_CALL_METHOD(result, pdo_statement, "fetch", PH_NO_CHECK);
    if (Z_TYPE_P(result) != IS_ARRAY) {
        PHALCON_MM_RESTORE();
        RETURN_NULL();
    }

    PHALCON_SEPARATE(n);
    increment_function(n);
    goto ws_a5eb_0;
we_a5eb_0:
    if(0) {}

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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