Example #1
0
/**
 * Reads parsed annotations from XCache
 *
 * @param string $key
 * @return Phalcon\Annotations\Reflection
 */
PHP_METHOD(Phalcon_Annotations_Adapter_Xcache, read){

	zval *key, *prefixed_key, *prefixed_lower, *serialized;
	zval *data;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &key);
	
	PHALCON_INIT_VAR(prefixed_key);
	PHALCON_CONCAT_SV(prefixed_key, "_PHAN", key);
	
	PHALCON_INIT_VAR(prefixed_lower);
	phalcon_fast_strtolower(prefixed_lower, prefixed_key);
	
	PHALCON_INIT_VAR(serialized);
	phalcon_call_func_p1(serialized, "xcache_get", prefixed_lower);
	if (Z_TYPE_P(serialized) == IS_STRING) {
	
		PHALCON_INIT_VAR(data);
		phalcon_unserialize(data, serialized TSRMLS_CC);
		if (Z_TYPE_P(data) == IS_OBJECT) {
			RETURN_CTOR(data);
		}
	}
	
	RETURN_MM_NULL();
}
Example #2
0
/**
 * Unserializing a resultset will allow to only works on the rows present in the saved state
 *
 * @param string $data
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, unserialize){

	zval *data, *resultset, *rows, *cache, *column_types;
	zval *hydrate_mode;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &data);
	
	phalcon_update_property_long(this_ptr, SL("_type"), 0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(resultset);
	phalcon_unserialize(resultset, data TSRMLS_CC);
	if (Z_TYPE_P(resultset) != IS_ARRAY) { 
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data");
		return;
	}
	
	PHALCON_OBS_VAR(rows);
	phalcon_array_fetch_string(&rows, resultset, SL("rows"), PH_NOISY);
	phalcon_update_property_this(this_ptr, SL("_rows"), rows TSRMLS_CC);
	
	PHALCON_OBS_VAR(cache);
	phalcon_array_fetch_string(&cache, resultset, SL("cache"), PH_NOISY);
	phalcon_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC);
	
	PHALCON_OBS_VAR(column_types);
	phalcon_array_fetch_string(&column_types, resultset, SL("columnTypes"), PH_NOISY);
	phalcon_update_property_this(this_ptr, SL("_columnTypes"), column_types TSRMLS_CC);
	
	PHALCON_OBS_VAR(hydrate_mode);
	phalcon_array_fetch_string(&hydrate_mode, resultset, SL("hydrateMode"), PH_NOISY);
	phalcon_update_property_this(this_ptr, SL("_hydrateMode"), hydrate_mode TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}