/** * Check if HTTP method match any of the passed methods * * @param string|array $methods * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isMethod) { zval *methods, *http_method, *is_equals = NULL, *method = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &methods) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(http_method); PHALCON_CALL_METHOD(http_method, this_ptr, "getmethod", PH_NO_CHECK); if (Z_TYPE_P(methods) == IS_STRING) { PHALCON_INIT_VAR(is_equals); is_equal_function(is_equals, methods, http_method TSRMLS_CC); RETURN_NCTOR(is_equals); } else { if (!phalcon_valid_foreach(methods TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(methods); 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_VALUE(method); PHALCON_INIT_NVAR(is_equals); is_equal_function(is_equals, method, http_method TSRMLS_CC); if (PHALCON_IS_TRUE(is_equals)) { PHALCON_MM_RESTORE(); RETURN_TRUE; } zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: if(0) {} } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Natural compare with long operandus on right */ int phalcon_compare_strict_long(zval *op1, long op2 TSRMLS_DC){ int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return Z_LVAL_P(op1) == op2; case IS_DOUBLE: return Z_LVAL_P(op1) == (double) op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 0 == op2; } else { return 1 == op2; } default: { zval result, op2_tmp; ZVAL_LONG(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; }
/** * Checks whether request has been made using ajax. Checks if $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isAjax) { zval requested_header = {}, xml_http_request = {}, requested_with = {}; PHALCON_STR(&requested_header, "HTTP_X_REQUESTED_WITH"); PHALCON_STR(&xml_http_request, "XMLHttpRequest"); PHALCON_CALL_METHODW(&requested_with, getThis(), "getheader", &requested_header); is_equal_function(return_value, &requested_with, &xml_http_request); return; }
/** * Starts a cache. The $keyname allow to identify the created fragment * * @param int|string $keyName * @return mixed */ PHP_METHOD(Phalcon_Cache_Backend, start){ zval *key_name = NULL, *backend = NULL, *front_end = NULL, *prefixed_key = NULL; zval *existing_cache = NULL, *fresh = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &key_name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_backendOptions"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(backend, t0); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, SL("_frontendObject"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(front_end, t1); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, SL("_prefix"), PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_VV(r0, t2, key_name); PHALCON_CPY_WRT(prefixed_key, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_METHOD_PARAMS_1(r1, this_ptr, "get", prefixed_key, PHALCON_NO_CHECK); PHALCON_CPY_WRT(existing_cache, r1); PHALCON_INIT_VAR(t3); ZVAL_NULL(t3); PHALCON_ALLOC_ZVAL_MM(r2); is_equal_function(r2, existing_cache, t3 TSRMLS_CC); if (zend_is_true(r2)) { PHALCON_INIT_VAR(fresh); ZVAL_BOOL(fresh, 1); PHALCON_CALL_METHOD_NORETURN(front_end, "start", PHALCON_NO_CHECK); } else { PHALCON_INIT_VAR(fresh); ZVAL_BOOL(fresh, 0); } phalcon_update_property_zval(this_ptr, SL("_fresh"), fresh TSRMLS_CC); phalcon_update_property_bool(this_ptr, SL("_started"), 1 TSRMLS_CC); RETURN_CHECK_CTOR(existing_cache); }
/** * Checks whether HTTP method is PATCH. if $_SERVER['REQUEST_METHOD']=='PATCH' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isPatch){ zval patch = {}, method = {}; if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) { RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "PATCH")); } PHALCON_STR(&patch, ISV(PATCH)); PHALCON_CALL_METHODW(&method, getThis(), "getmethod"); is_equal_function(return_value, &method, &patch); }
/** * Checks whether HTTP method is HEAD. if $_SERVER['REQUEST_METHOD']=='HEAD' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isHead){ zval head = {}, method = {}; if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) { RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "HEAD")); } PHALCON_STR(&head, ISV(HEAD)); PHALCON_CALL_METHODW(&method, getThis(), "getmethod"); is_equal_function(return_value, &method, &head); }
/** * Checks whether HTTP method is GET. if $_SERVER['REQUEST_METHOD']=='GET' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isGet){ zval get = {}, method = {}; if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) { RETURN_BOOL(!strcmp(phalcon_http_request_getmethod_helper(), "GET")); } PHALCON_STR(&get, ISV(GET)); PHALCON_CALL_METHODW(&method, getThis(), "getmethod"); is_equal_function(return_value, &method, &get); }
/** * Returns a route object by its name * * @return Phalcon\Mvc\Router\Route */ PHP_METHOD(Phalcon_Mvc_Router, getRouteByName) { zval *name = NULL, *routes = NULL, *route = NULL, *route_name = NULL, *is_equal = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(routes); phalcon_read_property(&routes, this_ptr, SL("_routes"), PH_NOISY_CC); if (!phalcon_valid_foreach(routes TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(routes); 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_VALUE(route); PHALCON_INIT_VAR(route_name); PHALCON_CALL_METHOD(route_name, route, "getname", PH_NO_CHECK); PHALCON_INIT_VAR(is_equal); is_equal_function(is_equal, route_name, name TSRMLS_CC); if (PHALCON_IS_TRUE(is_equal)) { RETURN_CCTOR(route); } zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Tell if the resultset if fresh or an old cached * * @return boolean */ PHP_METHOD(Phalcon_Model_Resultset, isFresh){ zval *t0 = NULL, *t1 = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_type", sizeof("_type")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_INIT_VAR(t1); ZVAL_LONG(t1, 1); PHALCON_ALLOC_ZVAL_MM(r0); is_equal_function(r0, t0, t1 TSRMLS_CC); PHALCON_RETURN_NCTOR(r0); }
/** * Checks whether HTTP method is OPTIONS * * @return boolean */ PHP_METHOD(Phalcon_Request, isOptions){ zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD(r0, this_ptr, "getmethod", PHALCON_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, "OPTIONS", 1); PHALCON_ALLOC_ZVAL_MM(r1); is_equal_function(r1, r0, t0 TSRMLS_CC); PHALCON_RETURN_NCTOR(r1); }
/** * Make a bulk save on all attached objects * * @return boolean */ PHP_METHOD(Phalcon_Transaction, save){ zval *a0 = NULL; zval *t0 = NULL, *t1 = NULL; zval *v0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); PHALCON_INIT_VAR(a0); array_init(a0); phalcon_update_property_zval(this_ptr, "_messages", strlen("_messages"), a0 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_dependencies", sizeof("_dependencies")-1, PHALCON_NOISY_FETCH TSRMLS_CC); if (Z_TYPE_P(t0) != IS_ARRAY) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument supplied for foreach()"); } else { ah0 = Z_ARRVAL_P(t0); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_815a_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_815a_0; } PHALCON_INIT_VAR(v0); ZVAL_ZVAL(v0, *hd, 1, 0); PHALCON_INIT_VAR(r0); PHALCON_CALL_METHOD(r0, v0, "save", PHALCON_CALL_DEFAULT); PHALCON_INIT_VAR(t1); ZVAL_BOOL(t1, 0); PHALCON_INIT_VAR(r1); is_equal_function(r1, r0, t1 TSRMLS_CC); if (zend_is_true(r1)) { PHALCON_INIT_VAR(r2); PHALCON_CALL_METHOD(r2, v0, "getmessages", PHALCON_CALL_DEFAULT); phalcon_update_property_zval(this_ptr, "_messages", strlen("_messages"), r2 TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_FALSE; } zend_hash_move_forward_ex(ah0, &hp0); goto fes_815a_0; fee_815a_0: if(0){ }; } PHALCON_MM_RESTORE(); RETURN_TRUE; }
/** * * Checks whether HTTP method is GET. if $_SERVER['REQUEST_METHOD']=='GET' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isGet){ zval *get, *method, *is_get; PHALCON_MM_GROW(); PHALCON_INIT_VAR(get); ZVAL_STRING(get, "GET", 1); PHALCON_INIT_VAR(method); phalcon_call_method(method, this_ptr, "getmethod"); PHALCON_INIT_VAR(is_get); is_equal_function(is_get, method, get TSRMLS_CC); RETURN_NCTOR(is_get); }
static zend_always_inline int __case_compare_function ( zval * result, zval * op1, zval * op2, int identical TSRMLS_DC ) { switch ( TYPE_PAIR ( Z_TYPE_P ( op1 ), Z_TYPE_P ( op2 ) ) ) { case TYPE_PAIR ( IS_STRING, IS_STRING ) : Z_LVAL_P ( result ) = zend_binary_zval_strcasecmp ( op1, op2 ) ; ZVAL_LONG ( result, ZEND_NORMALIZE_BOOL ( Z_LVAL_P ( result ) ) ) ; return ( SUCCESS ) ; default : return ( ( identical ) ? is_equal_function ( result, op1, op2 TSRMLS_CC ) : is_identical_function ( result, op1, op2 TSRMLS_CC ) ) ; } }
/** * Checks whether HTTP method is PUT. if $_SERVER['REQUEST_METHOD']=='PUT' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isPut){ zval *put, *method, *is_put; PHALCON_MM_GROW(); PHALCON_INIT_VAR(put); ZVAL_STRING(put, "PUT", 1); PHALCON_INIT_VAR(method); PHALCON_CALL_METHOD(method, this_ptr, "getmethod"); PHALCON_INIT_VAR(is_put); is_equal_function(is_put, method, put TSRMLS_CC); RETURN_NCTOR(is_put); }
/** * Checks whether HTTP method is HEAD. if $_SERVER['REQUEST_METHOD']=='HEAD' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isHead){ zval *head, *method, *is_head; PHALCON_MM_GROW(); PHALCON_INIT_VAR(head); ZVAL_STRING(head, "HEAD", 1); PHALCON_INIT_VAR(method); PHALCON_CALL_METHOD(method, this_ptr, "getmethod"); PHALCON_INIT_VAR(is_head); is_equal_function(is_head, method, head TSRMLS_CC); RETURN_NCTOR(is_head); }
/** * Checks whether HTTP method is PATCH. if $_SERVER['REQUEST_METHOD']=='PATCH' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isPatch){ zval *patch, *method, *is_patch; PHALCON_MM_GROW(); PHALCON_INIT_VAR(patch); ZVAL_STRING(patch, "PATCH", 1); PHALCON_INIT_VAR(method); PHALCON_CALL_METHOD(method, this_ptr, "getmethod"); PHALCON_INIT_VAR(is_patch); is_equal_function(is_patch, method, patch TSRMLS_CC); RETURN_NCTOR(is_patch); }
/** * Checks whether HTTP method is OPTIONS. if $_SERVER['REQUEST_METHOD']=='OPTIONS' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isOptions){ zval *method = NULL, *is_options = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(method); PHALCON_CALL_METHOD(method, this_ptr, "getmethod", PH_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, "OPTIONS", 1); PHALCON_INIT_VAR(is_options); is_equal_function(is_options, method, t0 TSRMLS_CC); RETURN_NCTOR(is_options); }
/** * Checks if the internal meta-data container is empty * * @return boolean */ PHP_METHOD(Phalcon_Model_MetaData, isEmpty){ zval *t0 = NULL, *t1 = NULL; zval *r0 = NULL, *r1 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_metaData"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r0); phalcon_fast_count(r0, t0 TSRMLS_CC); PHALCON_INIT_VAR(t1); ZVAL_LONG(t1, 0); PHALCON_ALLOC_ZVAL_MM(r1); is_equal_function(r1, r0, t1 TSRMLS_CC); RETURN_NCTOR(r1); }
/** * Checks whether HTTP method is POST. if $_SERVER['REQUEST_METHOD']=='POST' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isPost) { zval *post, *method, *is_post; PHALCON_MM_GROW(); PHALCON_INIT_VAR(post); ZVAL_STRING(post, "POST", 1); PHALCON_INIT_VAR(method); PHALCON_CALL_METHOD(method, this_ptr, "getmethod", PH_NO_CHECK); PHALCON_INIT_VAR(is_post); is_equal_function(is_post, method, post TSRMLS_CC); RETURN_NCTOR(is_post); }
/** * Tell if the resultset if fresh or an old cached * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh){ zval *type = NULL, *is_fresh = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(type); phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_INIT_VAR(is_fresh); is_equal_function(is_fresh, type, t0 TSRMLS_CC); RETURN_NCTOR(is_fresh); }
/** * Checks whether request has been made using ajax. Checks if $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isAjax){ zval *requested_header, *xml_http_request; zval *requested_with; PHALCON_MM_GROW(); PHALCON_INIT_VAR(requested_header); ZVAL_STRING(requested_header, "HTTP_X_REQUESTED_WITH", 1); PHALCON_INIT_VAR(xml_http_request); ZVAL_STRING(xml_http_request, "XMLHttpRequest", 1); PHALCON_INIT_VAR(requested_with); phalcon_call_method_p1(requested_with, this_ptr, "getheader", requested_header); is_equal_function(return_value, requested_with, xml_http_request TSRMLS_CC); RETURN_MM(); }
/** * Checks whether request has been made using ajax * * @return boolean */ PHP_METHOD(Phalcon_Request, isAjax){ zval *r0 = NULL, *r1 = NULL; zval *c0 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "HTTP_X_REQUESTED_WITH", 1); PHALCON_CALL_METHOD_PARAMS_1(r0, this_ptr, "getheader", c0, PHALCON_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, "XMLHttpRequest", 1); PHALCON_ALLOC_ZVAL_MM(r1); is_equal_function(r1, r0, t0 TSRMLS_CC); PHALCON_RETURN_NCTOR(r1); }
/** * Phalcon_Transaction constructor * * @param boolean $autoBegin */ PHP_METHOD(Phalcon_Transaction, __construct){ zval *a0 = NULL, *a1 = NULL; zval *v0 = NULL, *v1 = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; zval *p0[] = { NULL }; PHALCON_MM_GROW(); PHALCON_INIT_VAR(a0); array_init(a0); zend_update_property(phalcon_transaction_class_entry, this_ptr, "_dependencies", strlen("_dependencies"), a0 TSRMLS_CC); PHALCON_INIT_VAR(a1); array_init(a1); zend_update_property(phalcon_transaction_class_entry, this_ptr, "_messages", strlen("_messages"), a1 TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &v0) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!v0) { PHALCON_INIT_VAR(v0); ZVAL_BOOL(v0, 0); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_INIT_VAR(p0[0]); ZVAL_BOOL(p0[0], 1); PHALCON_CALL_STATIC_PARAMS(r0, "phalcon_db_pool", "getconnection", 1, p0); PHALCON_CPY_WRT(v1, r0); phalcon_update_property_zval(this_ptr, "_connection", strlen("_connection"), v1 TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_BOOL(t0, 1); PHALCON_ALLOC_ZVAL_MM(r1); is_equal_function(r1, v0, t0 TSRMLS_CC); if (zend_is_true(r1)) { PHALCON_CALL_METHOD_NORETURN(v1, "begin", PHALCON_CALL_DEFAULT); } PHALCON_MM_RESTORE(); RETURN_NULL(); }
/** * Checks whether request has been made using ajax * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isAjax){ zval *requested_header = NULL, *requested_with = NULL, *is_ajax = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(requested_header); ZVAL_STRING(requested_header, "HTTP_X_REQUESTED_WITH", 1); PHALCON_INIT_VAR(requested_with); PHALCON_CALL_METHOD_PARAMS_1(requested_with, this_ptr, "getheader", requested_header, PH_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, "XMLHttpRequest", 1); PHALCON_INIT_VAR(is_ajax); is_equal_function(is_ajax, requested_with, t0 TSRMLS_CC); RETURN_NCTOR(is_ajax); }
/** * Checks whether HTTP method is POST. if $_SERVER['REQUEST_METHOD']=='POST' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isPost){ zval *post, *method; if (Z_OBJCE_P(getThis()) == phalcon_http_request_ce) { const char *method = phalcon_http_request_getmethod_helper(TSRMLS_C); RETURN_BOOL(!strcmp(method, "POST")); } PHALCON_MM_GROW(); PHALCON_INIT_VAR(post); ZVAL_STRING(post, "POST", 1); PHALCON_INIT_VAR(method); phalcon_call_method(method, this_ptr, "getmethod"); is_equal_function(return_value, method, post TSRMLS_CC); RETURN_MM(); }
/** * Checks whether request has been made using ajax. Checks if $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest' * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isAjax){ zval *requested_header, *xml_http_request; zval *requested_with, *is_ajax; PHALCON_MM_GROW(); PHALCON_INIT_VAR(requested_header); ZVAL_STRING(requested_header, "HTTP_X_REQUESTED_WITH", 1); PHALCON_INIT_VAR(xml_http_request); ZVAL_STRING(xml_http_request, "XMLHttpRequest", 1); PHALCON_INIT_VAR(requested_with); PHALCON_CALL_METHOD_PARAMS_1(requested_with, this_ptr, "getheader", requested_header); PHALCON_INIT_VAR(is_ajax); is_equal_function(is_ajax, requested_with, xml_http_request TSRMLS_CC); RETURN_NCTOR(is_ajax); }
/** * Checks if the internal meta-data container is empty * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty){ zval *meta_data, *number, *is_empty; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(meta_data); phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC); PHALCON_INIT_VAR(number); phalcon_fast_count(number, meta_data TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 0); PHALCON_INIT_VAR(is_empty); is_equal_function(is_empty, number, t0 TSRMLS_CC); RETURN_NCTOR(is_empty); }
/** * Check if HTTP method match any of the passed methods * * @param string|array $methods * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isMethod){ zval *methods, http_method = {}, *method; phalcon_fetch_params(0, 1, 0, &methods); PHALCON_CALL_METHODW(&http_method, getThis(), "getmethod"); if (Z_TYPE_P(methods) == IS_STRING) { is_equal_function(return_value, methods, &http_method); return; } ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(methods), method) { if (PHALCON_IS_EQUAL(method, &http_method)) { RETURN_TRUE; } } ZEND_HASH_FOREACH_END(); RETURN_FALSE; }
/** * Check if HTTP method match any of the passed methods * * @param string|array $methods * @return boolean */ PHP_METHOD(Phalcon_Http_Request, isMethod){ zval *methods, *http_method, *is_equals, *method = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &methods) == FAILURE) { RETURN_MM_NULL(); } PHALCON_INIT_VAR(http_method); PHALCON_CALL_METHOD(http_method, this_ptr, "getmethod"); if (Z_TYPE_P(methods) == IS_STRING) { PHALCON_INIT_VAR(is_equals); is_equal_function(is_equals, methods, http_method TSRMLS_CC); RETURN_NCTOR(is_equals); } else { if (!phalcon_is_iterable(methods, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(method); if (PHALCON_IS_EQUAL(method, http_method)) { RETURN_MM_TRUE; } zend_hash_move_forward_ex(ah0, &hp0); } } RETURN_MM_FALSE; }
/** * Checks whether transaction is managed by a transaction manager * * @return boolean */ PHP_METHOD(Phalcon_Transaction, isManaged){ zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_manager", sizeof("_manager")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_INIT_VAR(t1); ZVAL_NULL(t1); PHALCON_ALLOC_ZVAL_MM(r1); is_equal_function(r1, t0, t1 TSRMLS_CC); if (zend_is_true(r1)) { PHALCON_INIT_VAR(t2); ZVAL_BOOL(t2, 0); r0 = t2; } else { PHALCON_INIT_VAR(t3); ZVAL_BOOL(t3, 1); r0 = t3; } PHALCON_RETURN_CHECK_CTOR(r0); }