示例#1
0
PHP_METHOD(Test_SpectralNorm, AtAu) {

	zval *n, *u, *v, *w;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &n, &u, &v, &w);



	zephir_call_method_p3_noret(this_ptr, "au", n, u, w);
	zephir_call_method_p3_noret(this_ptr, "atu", n, w, v);
	ZEPHIR_MM_RESTORE();

}
示例#2
0
/**
 * @param int timeout
 * @param string statement query statement
 * @param array vars [optional]
 * @return Statement object
 * @throws ConnectionException
 */
PHP_METHOD(ADOdb_Connection, cacheQuery) {

    zval *vars = NULL;
    zval *statement = NULL;
    zval *timeout_param = NULL, *statement_param = NULL, *vars_param = NULL, *_0, *queryId, *st = NULL, *_1, *_2, *_3 = NULL, *_4, *_5, _6, _7;
    int timeout;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 2, 1, &timeout_param, &statement_param, &vars_param);

    timeout = zephir_get_intval(timeout_param);
    zephir_get_strval(statement, statement_param);
    if (!vars_param) {
        ZEPHIR_INIT_VAR(vars);
        array_init(vars);
    } else {
        zephir_get_arrval(vars, vars_param);
    }


    _0 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
    if ((Z_TYPE_P(_0) != IS_NULL)) {
        _1 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
        ZEPHIR_INIT_VAR(queryId);
        zephir_call_method_p2(queryId, _1, "getqueryid", statement, vars);
        _2 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
        ZEPHIR_INIT_VAR(_3);
        ZVAL_LONG(_3, timeout);
        ZEPHIR_INIT_VAR(st);
        zephir_call_method_p2(st, _2, "read", queryId, _3);
        if (!zephir_is_true(st)) {
            ZEPHIR_INIT_NVAR(_3);
            ZVAL_STRING(_3, "Cache miss!", 1);
            zephir_call_method_p1_noret(this_ptr, "debug", _3);
            _4 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
            ZEPHIR_INIT_NVAR(st);
            zephir_call_method_p2(st, _4, "query", statement, vars);
            _5 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
            ZEPHIR_INIT_NVAR(_3);
            ZVAL_LONG(_3, timeout);
            zephir_call_method_p3_noret(_5, "write", queryId, st, _3);
        }
        RETURN_CCTOR(st);
    } else {
        ZEPHIR_SINIT_VAR(_6);
        ZVAL_STRING(&_6, "No cache engine found!", 0);
        ZEPHIR_SINIT_VAR(_7);
        ZVAL_LONG(&_7, 512);
        zephir_call_func_p2_noret("user_error", &_6, &_7);
        zephir_call_method_p2(return_value, this_ptr, "query", statement, vars);
        RETURN_MM();
    }
    ZEPHIR_MM_RESTORE();

}
示例#3
0
文件: router.c 项目: hobbit19/zephir
/**
 * Adds a route to the router without any HTTP constraint
 *
 *<code>
 * $router->add('/about', 'About::index');
 *</code>
 *
 * @param string pattern
 * @param string/array paths
 * @param string httpMethods
 * @return Test\Router\Route
 */
PHP_METHOD(Test_Router, add) {

    zval *pattern, *paths = NULL, *httpMethods = NULL, *route;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 1, 2, &pattern, &paths, &httpMethods);

    if (!paths) {
        paths = ZEPHIR_GLOBAL(global_null);
    }
    if (!httpMethods) {
        httpMethods = ZEPHIR_GLOBAL(global_null);
    }


    ZEPHIR_INIT_VAR(route);
    object_init_ex(route, test_router_route_ce);
    zephir_call_method_p3_noret(route, "__construct", pattern, paths, httpMethods);
    zephir_update_property_array_append(this_ptr, SL("_routes"), route TSRMLS_CC);
    RETURN_CCTOR(route);

}