本文整理汇总了C++中PHALCON_GET_FOREACH_KEY函数的典型用法代码示例。如果您正苦于以下问题:C++ PHALCON_GET_FOREACH_KEY函数的具体用法?C++ PHALCON_GET_FOREACH_KEY怎么用?C++ PHALCON_GET_FOREACH_KEY使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHALCON_GET_FOREACH_KEY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Sends the headers to the client
*
* @return boolean
*/
PHP_METHOD(Phalcon_Http_Response_Headers, send){
zval *headers_was_sent, *t, *headers, *value = NULL, *header = NULL;
zval *http_header = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
PHALCON_INIT_VAR(headers_was_sent);
PHALCON_CALL_FUNC(headers_was_sent, "headers_sent");
if (!zend_is_true(headers_was_sent)) {
PHALCON_INIT_VAR(t);
ZVAL_BOOL(t, 1);
PHALCON_INIT_VAR(headers);
phalcon_read_property(&headers, this_ptr, SL("_headers"), PH_NOISY_CC);
if (!phalcon_valid_foreach(headers TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(headers);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
ph_cycle_start_0:
if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {
goto ph_cycle_end_0;
}
PHALCON_GET_FOREACH_KEY(header, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(value);
if (zend_is_true(value)) {
PHALCON_INIT_NVAR(http_header);
PHALCON_CONCAT_VSV(http_header, header, ": ", value);
PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", http_header, t);
} else {
PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", header, t);
}
zend_hash_move_forward_ex(ah0, &hp0);
goto ph_cycle_start_0;
ph_cycle_end_0:
PHALCON_MM_RESTORE();
RETURN_TRUE;
}
PHALCON_MM_RESTORE();
RETURN_FALSE;
}
示例2: PHP_METHOD
/**
* Uncamelize strings which are camelized
*
*<code>
* echo Phalcon\Text::camelize('CocoBongo'); //coco_bongo
*</code>
*
* @param string $str
* @return string
*/
PHP_METHOD(Phalcon_Text, uncamelize){
zval *str = NULL, *patterns = NULL, *replacement = NULL, *pattern = NULL, *match_pattern = NULL;
zval *pattern_replace = NULL, *lower_pattern = NULL, *lower_str = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &str) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(patterns);
array_init(patterns);
add_assoc_stringl_ex(patterns, SL("/(?<=(?:[A-Z]))([A-Z]+)([A-Z][A-z])/")+1, SL("\\1_\\2"), 1);
add_assoc_stringl_ex(patterns, SL("/(?<=(?:[a-z]))([A-Z])/")+1, SL("_\\1"), 1);
if (!phalcon_valid_foreach(patterns TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(patterns);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_f8ee_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_f8ee_0;
}
PHALCON_INIT_VAR(pattern);
PHALCON_GET_FOREACH_KEY(pattern, ah0, hp0);
PHALCON_INIT_VAR(replacement);
ZVAL_ZVAL(replacement, *hd, 1, 0);
PHALCON_INIT_VAR(match_pattern);
PHALCON_CALL_FUNC_PARAMS_2(match_pattern, "preg_match", pattern, str);
if (zend_is_true(match_pattern)) {
PHALCON_INIT_VAR(pattern_replace);
PHALCON_CALL_FUNC_PARAMS_3(pattern_replace, "preg_replace", pattern, replacement, str);
PHALCON_INIT_VAR(lower_pattern);
PHALCON_CALL_FUNC_PARAMS_1(lower_pattern, "strtolower", pattern_replace);
RETURN_CTOR(lower_pattern);
}
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_f8ee_0;
fee_f8ee_0:
PHALCON_INIT_VAR(lower_str);
PHALCON_CALL_FUNC_PARAMS_1(lower_str, "strtolower", str);
RETURN_CTOR(lower_str);
}
示例3: PHP_METHOD
/**
* Renders a view using the template engine
*
* @param string $path
* @param array $params
* @param bool $mustClean
*/
PHP_METHOD(Phalcon_Mvc_View_Engine_Php, render){
zval *path = NULL, *params = NULL, *must_clean = NULL, *value = NULL, *key = NULL, *contents = NULL;
zval *view = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &path, ¶ms, &must_clean) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(must_clean) == IS_BOOL && Z_BVAL_P(must_clean)) {
PHALCON_CALL_FUNC_NORETURN("ob_clean");
}
if (!phalcon_valid_foreach(params TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(params);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_1897_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_1897_0;
}
PHALCON_INIT_VAR(key);
PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
if (phalcon_set_symbol(key, value TSRMLS_CC) == FAILURE){
return;
}
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_1897_0;
fee_1897_0:
if (phalcon_require(path TSRMLS_CC) == FAILURE) {
return;
}
if (Z_TYPE_P(must_clean) == IS_BOOL && Z_BVAL_P(must_clean)) {
PHALCON_INIT_VAR(contents);
PHALCON_CALL_FUNC(contents, "ob_get_contents");
PHALCON_INIT_VAR(view);
phalcon_read_property(&view, this_ptr, SL("_view"), PH_NOISY_CC);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(view, "setcontent", contents, PH_NO_CHECK);
}
PHALCON_MM_RESTORE();
}
示例4: PHP_METHOD
/**
* Returns the annotations found in the properties' docblocks
*
* @return Phalcon\Annotations\Collection[]
*/
PHP_METHOD(Phalcon_Annotations_Reflection, getPropertiesAnnotations){
zval *annotations, *reflection_data, *reflection_properties;
zval *collections, *reflection_property = NULL, *property = NULL;
zval *collection = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
PHALCON_OBS_VAR(annotations);
phalcon_read_property(&annotations, this_ptr, SL("_propertyAnnotations"), PH_NOISY_CC);
if (Z_TYPE_P(annotations) != IS_OBJECT) {
PHALCON_OBS_VAR(reflection_data);
phalcon_read_property(&reflection_data, this_ptr, SL("_reflectionData"), PH_NOISY_CC);
if (phalcon_array_isset_string(reflection_data, SS("properties"))) {
PHALCON_OBS_VAR(reflection_properties);
phalcon_array_fetch_string(&reflection_properties, reflection_data, SL("properties"), PH_NOISY_CC);
if (phalcon_fast_count_ev(reflection_properties TSRMLS_CC)) {
PHALCON_INIT_VAR(collections);
array_init(collections);
if (!phalcon_is_iterable(reflection_properties, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(property, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(reflection_property);
PHALCON_INIT_NVAR(collection);
object_init_ex(collection, phalcon_annotations_collection_ce);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(collection, "__construct", reflection_property);
phalcon_array_update_zval(&collections, property, &collection, PH_COPY | PH_SEPARATE TSRMLS_CC);
zend_hash_move_forward_ex(ah0, &hp0);
}
phalcon_update_property_zval(this_ptr, SL("_propertyAnnotations"), collections TSRMLS_CC);
RETURN_CTOR(collections);
}
}
phalcon_update_property_bool(this_ptr, SL("_propertyAnnotations"), 0 TSRMLS_CC);
RETURN_MM_FALSE;
}
RETURN_CCTOR(annotations);
}
示例5: PHP_METHOD
/**
* Sets the default descriptor for database connections.
*
*
*
* @param array $options
* @return boolean
*/
PHP_METHOD(Phalcon_Db_Pool, setDefaultDescriptor){
zval *options = NULL, *descriptor = NULL, *value = NULL, *key = NULL;
zval *i0 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &options) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(options) != IS_ARRAY) {
if (Z_TYPE_P(options) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The parameter 'options' must be an Array or Object");
return;
}
}
if (Z_TYPE_P(options) == IS_ARRAY) {
PHALCON_ALLOC_ZVAL_MM(i0);
object_init(i0);
PHALCON_CPY_WRT(descriptor, i0);
if (phalcon_valid_foreach(options TSRMLS_CC)) {
ah0 = Z_ARRVAL_P(options);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_162f_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_162f_0;
} else {
PHALCON_INIT_VAR(key);
PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
}
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
phalcon_update_property_zval_zval(descriptor, key, value TSRMLS_CC);
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_162f_0;
fee_162f_0:
if(0){}
} else {
return;
}
} else {
PHALCON_CPY_WRT(descriptor, options);
}
phalcon_update_static_property(SL("Phalcon_Db_Pool"), SL("_defaultDescriptor"), descriptor TSRMLS_CC);
PHALCON_MM_RESTORE();
}
示例6: PHP_METHOD
/**
* Renders a view using the template engine
*
* @param string $path
* @param array $params
* @param boolean $mustClean
*/
PHP_METHOD(Phalcon_Mvc_View_Engine_Php, render){
zval *path, *params, *must_clean = NULL, *value = NULL, *key = NULL, *contents;
zval *view;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &path, ¶ms, &must_clean) == FAILURE) {
RETURN_MM_NULL();
}
if (!must_clean) {
PHALCON_INIT_VAR(must_clean);
ZVAL_BOOL(must_clean, 0);
}
if (PHALCON_IS_TRUE(must_clean)) {
PHALCON_CALL_FUNC_NORETURN("ob_clean");
}
if (Z_TYPE_P(params) == IS_ARRAY) {
if (!phalcon_is_iterable(params, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(value);
if (phalcon_set_symbol(key, value TSRMLS_CC) == FAILURE){
return;
}
zend_hash_move_forward_ex(ah0, &hp0);
}
}
if (phalcon_require(path TSRMLS_CC) == FAILURE) {
return;
}
if (PHALCON_IS_TRUE(must_clean)) {
PHALCON_INIT_VAR(contents);
PHALCON_CALL_FUNC(contents, "ob_get_contents");
PHALCON_OBS_VAR(view);
phalcon_read_property(&view, this_ptr, SL("_view"), PH_NOISY_CC);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(view, "setcontent", contents);
}
PHALCON_MM_RESTORE();
}
示例7: PHP_METHOD
/**
* Returns the annotations found in a specific property
*
* @param string $className
* @param string $propertyName
* @return Phalcon\Annotations\Collection
*/
PHP_METHOD(Phalcon_Annotations_Adapter, getProperty){
zval *class_name, *property_name, *class_annotations;
zval *properties, *property = NULL, *name = NULL, *collection;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &class_name, &property_name);
/**
* Get the full annotations from the class
*/
PHALCON_INIT_VAR(class_annotations);
PHALCON_CALL_METHOD_PARAMS_1(class_annotations, this_ptr, "get", class_name);
/**
* A valid annotations reflection is an object
*/
if (Z_TYPE_P(class_annotations) == IS_OBJECT) {
PHALCON_INIT_VAR(properties);
PHALCON_CALL_METHOD(properties, class_annotations, "getpropertyannotations");
if (Z_TYPE_P(properties) == IS_ARRAY) {
if (!phalcon_is_iterable(properties, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(name, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(property);
if (PHALCON_IS_EQUAL(name, property_name)) {
RETURN_CCTOR(property);
}
zend_hash_move_forward_ex(ah0, &hp0);
}
}
}
/**
* Returns a collection anyways
*/
PHALCON_INIT_VAR(collection);
object_init_ex(collection, phalcon_annotations_collection_ce);
PHALCON_CALL_METHOD_NORETURN(collection, "__construct");
RETURN_CTOR(collection);
}
示例8: PHP_METHOD
/**
* Prints the messages in the session flasher
*
* @param string $type
* @param boolean $remove
*/
PHP_METHOD(Phalcon_Flash_Session, output){
zval *remove = NULL, *messages, *message = NULL, *type = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &remove) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!remove) {
PHALCON_INIT_NVAR(remove);
ZVAL_BOOL(remove, 1);
}
PHALCON_INIT_VAR(messages);
PHALCON_CALL_METHOD_PARAMS_1(messages, this_ptr, "_getsessionmessages", remove, PH_NO_CHECK);
if (Z_TYPE_P(messages) == IS_ARRAY) {
if (!phalcon_valid_foreach(messages TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(messages);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
ph_cycle_start_0:
if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {
goto ph_cycle_end_0;
}
PHALCON_GET_FOREACH_KEY(type, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(message);
PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "outputmessage", type, message, PH_NO_CHECK);
zend_hash_move_forward_ex(ah0, &hp0);
goto ph_cycle_start_0;
ph_cycle_end_0:
if(0){}
}
PHALCON_MM_RESTORE();
}
示例9: PHP_METHOD
/**
* Returns the messages generated in the validation
*
* @param boolean $byItemName
* @return array
*/
PHP_METHOD(Phalcon_Forms_Form, getMessages){
zval *by_item_name = NULL, *messages, *group = NULL, *element_messages = NULL;
zval *element = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &by_item_name) == FAILURE) {
RETURN_MM_NULL();
}
if (!by_item_name) {
PHALCON_INIT_VAR(by_item_name);
ZVAL_BOOL(by_item_name, 0);
}
PHALCON_OBS_VAR(messages);
phalcon_read_property(&messages, this_ptr, SL("_messages"), PH_NOISY_CC);
if (zend_is_true(by_item_name)) {
if (Z_TYPE_P(messages) != IS_ARRAY) {
PHALCON_INIT_VAR(group);
object_init_ex(group, phalcon_validation_message_group_ce);
PHALCON_CALL_METHOD_NORETURN(group, "__construct");
RETURN_CTOR(group);
}
RETURN_CCTOR(messages);
}
PHALCON_INIT_NVAR(group);
object_init_ex(group, phalcon_validation_message_group_ce);
PHALCON_CALL_METHOD_NORETURN(group, "__construct");
if (!phalcon_is_iterable(messages, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(element, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(element_messages);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(group, "appendmessages", element_messages);
zend_hash_move_forward_ex(ah0, &hp0);
}
RETURN_CTOR(group);
}
示例10: PHP_METHOD
/**
* Resets the request and internal values to avoid those fields will have any default value
*/
PHP_METHOD(Phalcon_Tag, resetInput){
zval *value = NULL, *key = NULL;
zval *a0 = NULL;
zval *g0 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
PHALCON_MM_GROW();
PHALCON_ALLOC_ZVAL_MM(a0);
array_init(a0);
phalcon_update_static_property(SL("phalcon\\tag"), SL("_displayValues"), a0 TSRMLS_CC);
phalcon_get_global(&g0, SL("_POST")+1 TSRMLS_CC);
if (!phalcon_valid_foreach(g0 TSRMLS_CC)) {
return;
}
ALLOC_HASHTABLE(ah0);
zend_hash_init(ah0, 0, NULL, NULL, 0);
zend_hash_copy(ah0, Z_ARRVAL_P(g0), NULL, NULL, sizeof(zval*));
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_9b93_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_9b93_0;
}
PHALCON_INIT_VAR(key);
PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
phalcon_array_unset(g0, key);
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_9b93_0;
fee_9b93_0:
zend_hash_destroy(ah0);
efree(ah0);
PHALCON_MM_RESTORE();
}
示例11: PHP_METHOD
/**
* Prints the messages in the session flasher
*
* @param string $type
* @param boolean $remove
*/
PHP_METHOD(Phalcon_Flash_Session, output){
zval *remove = NULL, *messages, *message = NULL, *type = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &remove) == FAILURE) {
RETURN_MM_NULL();
}
if (!remove) {
PHALCON_INIT_VAR(remove);
ZVAL_BOOL(remove, 1);
}
PHALCON_INIT_VAR(messages);
PHALCON_CALL_METHOD_PARAMS_1(messages, this_ptr, "_getsessionmessages", remove);
if (Z_TYPE_P(messages) == IS_ARRAY) {
if (!phalcon_is_iterable(messages, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(type, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(message);
PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "outputmessage", type, message);
zend_hash_move_forward_ex(ah0, &hp0);
}
}
PHALCON_MM_RESTORE();
}
示例12: PHP_METHOD
//.........这里部分代码省略.........
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);
PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
}
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
if (Z_TYPE_P(key) == IS_LONG) {
PHALCON_INIT_VAR(r12);
phalcon_array_fetch(&r12, parts, key, PHALCON_NOISY TSRMLS_CC);
phalcon_array_append(¶ms, r12, PHALCON_SEPARATE_PLZ TSRMLS_CC);
}
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_e10f_1;
fee_e10f_1:
if(0){}
} else {
return;
}
phalcon_update_property_zval(this_ptr, SL("_params"), params TSRMLS_CC);
phalcon_update_property_bool(this_ptr, SL("_finished"), 0 TSRMLS_CC);
PHALCON_MM_RESTORE();
}
示例13: PHP_METHOD
/**
* Updates data on a table using custom RBDM SQL syntax
*
* @param string $table
* @param array $fields
* @param array $values
* @param string $whereCondition
* @return boolean
*/
PHP_METHOD(Phalcon_Db, update){
zval *table = NULL, *fields = NULL, *values = NULL, *where_condition = NULL;
zval *placeholders = NULL, *value = NULL, *position = NULL, *field = NULL, *set_clause_part = NULL;
zval *comma = NULL, *set_clause = NULL, *update_sql = NULL, *success = 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, "zzz|z", &table, &fields, &values, &where_condition) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_SEPARATE_PARAM(values);
if (!where_condition) {
PHALCON_ALLOC_ZVAL_MM(where_condition);
ZVAL_NULL(where_condition);
}
PHALCON_INIT_VAR(placeholders);
array_init(placeholders);
if (!phalcon_valid_foreach(values TSRMLS_CC)) {
return;
}
ALLOC_HASHTABLE(ah0);
zend_hash_init(ah0, 0, NULL, NULL, 0);
zend_hash_copy(ah0, Z_ARRVAL_P(values), NULL, NULL, sizeof(zval*));
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
ph_cycle_start_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto ph_cycle_end_0;
}
PHALCON_INIT_VAR(position);
PHALCON_GET_FOREACH_KEY(position, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(value);
eval_int = phalcon_array_isset(fields, position);
if (eval_int) {
PHALCON_INIT_VAR(field);
phalcon_array_fetch(&field, fields, position, PH_NOISY_CC);
if (Z_TYPE_P(value) == IS_OBJECT) {
PHALCON_INIT_VAR(set_clause_part);
PHALCON_CONCAT_VSV(set_clause_part, field, " = ", value);
phalcon_array_append(&placeholders, set_clause_part, PH_SEPARATE TSRMLS_CC);
PHALCON_SEPARATE_PARAM(values);
phalcon_array_unset(values, position);
} else {
if (Z_TYPE_P(value) == IS_NULL) {
PHALCON_INIT_VAR(set_clause_part);
PHALCON_CONCAT_VS(set_clause_part, field, " = null");
PHALCON_SEPARATE_PARAM(values);
phalcon_array_unset(values, position);
} else {
PHALCON_INIT_VAR(set_clause_part);
PHALCON_CONCAT_VS(set_clause_part, field, " = ?");
}
phalcon_array_append(&placeholders, set_clause_part, PH_SEPARATE TSRMLS_CC);
}
} else {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The number of values in the update is not the same as fields");
return;
}
zend_hash_move_forward_ex(ah0, &hp0);
goto ph_cycle_start_0;
ph_cycle_end_0:
zend_hash_destroy(ah0);
efree(ah0);
PHALCON_INIT_VAR(comma);
ZVAL_STRING(comma, ", ", 1);
PHALCON_INIT_VAR(set_clause);
phalcon_fast_join(set_clause, comma, placeholders TSRMLS_CC);
if (Z_TYPE_P(where_condition) != IS_NULL) {
PHALCON_INIT_VAR(update_sql);
//.........这里部分代码省略.........
示例14: PHP_METHOD
/**
* Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST
*
* @param Phalcon\DI $dependencyInjector
* @param string $modelName
* @param array $data
*/
PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput){
zval *dependency_injector = NULL, *model_name = NULL, *data = NULL;
zval *conditions = NULL, *number_data = NULL, *service = NULL, *meta_data = NULL;
zval *model = NULL, *data_types = NULL, *bind = NULL, *value = NULL, *field = NULL, *type = NULL;
zval *condition = NULL, *value_pattern = NULL, *criteria = NULL, *number_conditions = NULL;
zval *join_conditions = NULL;
zval *c0 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
int eval_int;
zend_class_entry *ce0;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &dependency_injector, &model_name, &data) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(data) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Input data must be an Array");
return;
}
if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A dependency injector container is required to obtain the ORM services");
return;
}
PHALCON_INIT_VAR(conditions);
array_init(conditions);
PHALCON_INIT_VAR(number_data);
phalcon_fast_count(number_data, data TSRMLS_CC);
if (!phalcon_compare_strict_long(number_data, 0 TSRMLS_CC)) {
PHALCON_INIT_VAR(service);
ZVAL_STRING(service, "modelsMetadata", 1);
PHALCON_INIT_VAR(meta_data);
PHALCON_CALL_METHOD_PARAMS_1(meta_data, dependency_injector, "getshared", service, PH_NO_CHECK);
ce0 = phalcon_fetch_class(model_name TSRMLS_CC);
PHALCON_INIT_VAR(model);
object_init_ex(model, ce0);
PHALCON_CALL_METHOD_NORETURN(model, "__construct", PH_CHECK);
PHALCON_INIT_VAR(data_types);
PHALCON_CALL_METHOD_PARAMS_1(data_types, meta_data, "getdatatypes", model, PH_NO_CHECK);
PHALCON_INIT_VAR(bind);
array_init(bind);
if (!phalcon_valid_foreach(data TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(data);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_1d26_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_1d26_0;
}
PHALCON_INIT_VAR(field);
PHALCON_GET_FOREACH_KEY(field, ah0, hp0);
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
eval_int = phalcon_array_isset(data_types, field);
if (eval_int) {
if (Z_TYPE_P(value) != IS_NULL) {
if (!PHALCON_COMPARE_STRING(value, "")) {
PHALCON_INIT_VAR(type);
phalcon_array_fetch(&type, data_types, field, PH_NOISY_CC);
if (phalcon_compare_strict_long(type, 2 TSRMLS_CC)) {
PHALCON_INIT_VAR(condition);
PHALCON_CONCAT_VSVS(condition, field, " LIKE :", field, ":");
PHALCON_INIT_VAR(value_pattern);
PHALCON_CONCAT_SVS(value_pattern, "%", value, "%");
phalcon_array_update_zval(&bind, field, &value_pattern, PH_COPY | PH_SEPARATE TSRMLS_CC);
} else {
PHALCON_INIT_VAR(condition);
PHALCON_CONCAT_VSVS(condition, field, "=:", field, ":");
phalcon_array_update_zval(&bind, field, &value, PH_COPY | PH_SEPARATE TSRMLS_CC);
}
phalcon_array_append(&conditions, condition, PH_SEPARATE TSRMLS_CC);
}
}
//.........这里部分代码省略.........
示例15: PHP_METHOD
/**
* Makes the work of autoload registered classes
*
* @param string $className
* @return boolean
*/
PHP_METHOD(Phalcon_Loader, autoLoad){
zval *class_name = NULL, *file_name = NULL, *directory = NULL, *preffix = NULL;
zval *path = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = 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;
zval *c0 = NULL, *c1 = NULL, *c2 = NULL;
HashTable *ah0, *ah1;
HashPosition hp0, hp1;
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", &class_name) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, SL("_classes"), PHALCON_NOISY TSRMLS_CC);
eval_int = phalcon_array_isset(t0, class_name);
if (eval_int) {
PHALCON_ALLOC_ZVAL_MM(t1);
phalcon_read_property(&t1, this_ptr, SL("_classes"), PHALCON_NOISY TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r0);
phalcon_array_fetch(&r0, t1, class_name, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(file_name, r0);
if (phalcon_require(file_name TSRMLS_CC) == FAILURE) {
return;
}
PHALCON_MM_RESTORE();
RETURN_TRUE;
}
PHALCON_ALLOC_ZVAL_MM(t2);
phalcon_read_property(&t2, this_ptr, SL("_namespaces"), PHALCON_NOISY TSRMLS_CC);
if (phalcon_valid_foreach(t2 TSRMLS_CC)) {
ah0 = Z_ARRVAL_P(t2);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_0c08_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_0c08_0;
} else {
PHALCON_INIT_VAR(preffix);
PHALCON_GET_FOREACH_KEY(preffix, ah0, hp0);
}
PHALCON_INIT_VAR(directory);
ZVAL_ZVAL(directory, *hd, 1, 0);
PHALCON_INIT_VAR(r1);
PHALCON_CALL_FUNC_PARAMS_1(r1, "strlen", class_name);
PHALCON_INIT_VAR(r2);
is_smaller_function(r2, preffix, r1 TSRMLS_CC);
if (zend_is_true(r2)) {
PHALCON_INIT_VAR(c0);
ZVAL_LONG(c0, 0);
PHALCON_INIT_VAR(r3);
PHALCON_CALL_FUNC_PARAMS_1(r3, "strlen", preffix);
PHALCON_INIT_VAR(r4);
PHALCON_CALL_FUNC_PARAMS_3(r4, "substr", class_name, c0, r3);
PHALCON_INIT_VAR(r5);
is_equal_function(r5, r4, preffix TSRMLS_CC);
if (zend_is_true(r5)) {
PHALCON_INIT_VAR(r6);
PHALCON_CONCAT_VS(r6, preffix, "\\");
PHALCON_INIT_VAR(c1);
ZVAL_STRING(c1, "", 1);
PHALCON_INIT_VAR(r7);
phalcon_fast_str_replace(r7, r6, c1, class_name TSRMLS_CC);
PHALCON_CPY_WRT(file_name, r7);
if (zend_is_true(file_name)) {
PHALCON_INIT_VAR(c2);
ZVAL_STRING(c2, "\\", 1);
PHALCON_INIT_VAR(t3);
zend_get_constant("DIRECTORY_SEPARATOR", strlen("DIRECTORY_SEPARATOR"), t3 TSRMLS_CC);
PHALCON_INIT_VAR(r8);
PHALCON_CONCAT_VVS(r8, directory, file_name, ".php");
PHALCON_INIT_VAR(r9);
phalcon_fast_str_replace(r9, c2, t3, r8 TSRMLS_CC);
PHALCON_CPY_WRT(path, r9);
if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) {
if (phalcon_require(path TSRMLS_CC) == FAILURE) {
return;
}
PHALCON_MM_RESTORE();
RETURN_TRUE;
}
}
}
//.........这里部分代码省略.........