本文整理汇总了C++中zend_is_true函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_is_true函数的具体用法?C++ zend_is_true怎么用?C++ zend_is_true使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zend_is_true函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Stores cached content into the APC backend and stops the frontend
*
* @param string $keyName
* @param string $content
* @param long $lifetime
* @param boolean $stopBuffer
*/
PHP_METHOD(Phalcon_Cache_Backend_Apc, save) {
zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *last_key = NULL, *prefix, *frontend, *cached_content = NULL;
zval *prepared_content, *ttl = NULL, *is_buffering;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzzz", &key_name, &content, &lifetime, &stop_buffer) == FAILURE) {
RETURN_MM_NULL();
}
if (!key_name) {
PHALCON_INIT_VAR(key_name);
}
if (!content) {
PHALCON_INIT_VAR(content);
}
if (!lifetime) {
PHALCON_INIT_VAR(lifetime);
}
if (!stop_buffer) {
PHALCON_INIT_VAR(stop_buffer);
ZVAL_BOOL(stop_buffer, 1);
}
if (Z_TYPE_P(key_name) == IS_NULL) {
PHALCON_OBS_VAR(last_key);
phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC);
} else {
PHALCON_OBS_VAR(prefix);
phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC);
PHALCON_INIT_NVAR(last_key);
PHALCON_CONCAT_SVV(last_key, "_PHCA", prefix, key_name);
}
if (!zend_is_true(last_key)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");
return;
}
PHALCON_OBS_VAR(frontend);
phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
if (Z_TYPE_P(content) == IS_NULL) {
PHALCON_INIT_VAR(cached_content);
PHALCON_CALL_METHOD(cached_content, frontend, "getcontent");
} else {
PHALCON_CPY_WRT(cached_content, content);
}
PHALCON_INIT_VAR(prepared_content);
PHALCON_CALL_METHOD_PARAMS_1(prepared_content, frontend, "beforestore", cached_content);
if (Z_TYPE_P(lifetime) == IS_NULL) {
PHALCON_INIT_VAR(ttl);
PHALCON_CALL_METHOD(ttl, frontend, "getlifetime");
} else {
PHALCON_CPY_WRT(ttl, lifetime);
}
PHALCON_CALL_FUNC_PARAMS_3_NORETURN("apc_store", last_key, prepared_content, ttl);
PHALCON_INIT_VAR(is_buffering);
PHALCON_CALL_METHOD(is_buffering, frontend, "isbuffering");
if (PHALCON_IS_TRUE(stop_buffer)) {
PHALCON_CALL_METHOD_NORETURN(frontend, "stop");
}
if (PHALCON_IS_TRUE(is_buffering)) {
zend_print_zval(cached_content, 0);
}
phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
PHALCON_MM_RESTORE();
}
示例2: PHP_METHOD
/**
* Stores cached content into the Memcached backend and stops the frontend
*
* @param int|string $keyName
* @param string $content
* @param long $lifetime
* @param boolean $stopBuffer
*/
PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){
zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL, last_key = {}, prefix = {}, cached_content = {}, prepared_content = {}, ttl = {}, flags = {}, success = {};
zval keys = {}, is_buffering = {}, frontend = {}, memcache = {}, options = {}, special_key = {};
phalcon_fetch_params(0, 0, 4, &key_name, &content, &lifetime, &stop_buffer);
if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {
phalcon_return_property(&last_key, getThis(), SL("_lastKey"));
} else {
phalcon_return_property(&prefix, getThis(), SL("_prefix"));
PHALCON_CONCAT_VV(&last_key, &prefix, key_name);
}
if (!zend_is_true(&last_key)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "The cache must be started first");
return;
}
phalcon_return_property(&frontend, getThis(), SL("_frontend"));
/**
* Check if a connection is created or make a new one
*/
phalcon_return_property(&memcache, getThis(), SL("_memcache"));
if (Z_TYPE(memcache) != IS_OBJECT) {
PHALCON_CALL_METHODW(&memcache, getThis(), "_connect");
}
if (!content || Z_TYPE_P(content) == IS_NULL) {
PHALCON_CALL_METHODW(&cached_content, &frontend, "getcontent");
} else {
PHALCON_CPY_WRT(&cached_content, content);
}
/**
* Prepare the content in the frontend
*/
PHALCON_CALL_METHODW(&prepared_content, &frontend, "beforestore", &cached_content);
if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) {
phalcon_return_property(&ttl, getThis(), SL("_lastLifetime"));
if (Z_TYPE(ttl) == IS_NULL) {
PHALCON_CALL_METHODW(&ttl, &frontend, "getlifetime");
}
} else {
PHALCON_CPY_WRT(&ttl, lifetime);
}
ZVAL_LONG(&flags, 0);
/**
* We store without flags
*/
if (phalcon_is_numeric(&cached_content)) {
PHALCON_CALL_METHODW(&success, &memcache, "set", &last_key, &cached_content, &flags, &ttl);
} else {
PHALCON_CALL_METHODW(&success, &memcache, "set", &last_key, &prepared_content, &flags, &ttl);
}
if (!zend_is_true(&success)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "Failed to store data in memcached");
return;
}
phalcon_return_property(&options, getThis(), SL("_options"));
if (unlikely(!phalcon_array_isset_fetch_str(&special_key, &options, SL("statsKey")))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "Unexpected inconsistency in options");
return;
}
if (Z_TYPE(special_key) != IS_NULL) {
/* Update the stats key */
PHALCON_CALL_METHODW(&keys, &memcache, "get", &special_key);
if (Z_TYPE(keys) != IS_ARRAY) {
array_init(&keys);
}
if (!phalcon_array_isset(&keys, &last_key)) {
phalcon_array_update_zval(&keys, &last_key, &ttl, PH_COPY);
PHALCON_CALL_METHODW(NULL, &memcache, "set", &special_key, &keys);
}
}
PHALCON_CALL_METHODW(&is_buffering, &frontend, "isbuffering");
if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) {
PHALCON_CALL_METHODW(NULL, &frontend, "stop");
}
//.........这里部分代码省略.........
示例3: PHP_METHOD
/**
* Generates a URL
*
*<code>
*
* //Generate a URL appending the URI to the base URI
* echo $url->get('products/edit/1');
*
* //Generate a URL for a predefined route
* echo $url->get(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012'));
* echo $url->get(array('for' => 'blog-post', 'hostname' => true, 'title' => 'some-cool-stuff', 'year' => '2012'));
*
*</code>
*
* @param string|array $uri
* @param array|object args Optional arguments to be appended to the query string
* @param bool|null $local
* @return string
*/
PHP_METHOD(Phalcon_Mvc_Url, get){
zval *uri = NULL, *args = NULL, *local = NULL, *base_uri = NULL, *router = NULL, *dependency_injector;
zval *service, *route_name, *hostname, *route = NULL, *exception_message;
zval *pattern = NULL, *paths = NULL, *processed_uri = NULL, *query_string;
zval *matched, *regexp;
zval *generator = NULL, *arguments;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 3, &uri, &args, &local);
if (!uri) {
uri = &PHALCON_GLOBAL(z_null);
}
if (!args) {
args = &PHALCON_GLOBAL(z_null);
}
if (!local) {
local = &PHALCON_GLOBAL(z_null);
} else {
PHALCON_SEPARATE_PARAM(local);
}
PHALCON_CALL_METHOD(&base_uri, getThis(), "getbaseuri");
if (Z_TYPE_P(uri) == IS_STRING) {
if (strstr(Z_STRVAL_P(uri), ":")) {
PHALCON_INIT_VAR(matched);
PHALCON_INIT_VAR(regexp);
ZVAL_STRING(regexp, "/^[^:\\/?#]++:/");
RETURN_MM_ON_FAILURE(phalcon_preg_match(matched, regexp, uri, NULL));
if (zend_is_true(matched)) {
PHALCON_INIT_NVAR(local);
ZVAL_FALSE(local);
}
}
if (Z_TYPE_P(local) == IS_NULL || zend_is_true(local)) {
PHALCON_CONCAT_VV(return_value, base_uri, uri);
} else {
ZVAL_ZVAL(return_value, uri, 1, 0);
}
} else if (Z_TYPE_P(uri) == IS_ARRAY) {
if (!phalcon_array_isset_str_fetch(&route_name, uri, SL("for"))) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter \"for\"");
return;
}
router = phalcon_read_property(getThis(), SL("_router"), PH_NOISY);
/**
* Check if the router has not previously set
*/
if (Z_TYPE_P(router) != IS_OBJECT) {
dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY);
if (!zend_is_true(dependency_injector)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the \"url\" service");
return;
}
PHALCON_INIT_VAR(service);
ZVAL_STR(service, IS(router));
router = NULL;
PHALCON_CALL_METHOD(&router, dependency_injector, "getshared", service);
PHALCON_VERIFY_INTERFACE(router, phalcon_mvc_routerinterface_ce);
phalcon_update_property_this(getThis(), SL("_router"), router);
}
/**
* Every route is uniquely identified by a name
*/
PHALCON_CALL_METHOD(&route, router, "getroutebyname", route_name);
if (Z_TYPE_P(route) != IS_OBJECT) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Cannot obtain a route using the name \"", route_name, "\"");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_url_exception_ce, exception_message);
return;
//.........这里部分代码省略.........
示例4: PHP_METHOD
/**
* Dispatches a controller action taking into account the routing parameters
*
* @param Phalcon_Request $request
* @param Phalcon_Response $response
* @param Phalcon_View $view
* @param Phalcon_Model_Manager $model
* @return Phalcon_Controller
*/
PHP_METHOD(Phalcon_Dispatcher, dispatch){
zval *request = NULL, *response = NULL, *view = NULL, *model = NULL, *controllers_dir = NULL;
zval *value = NULL, *controller = NULL, *number_dispatches = NULL;
zval *controller_name = NULL, *controllers = NULL, *controller_class = NULL;
zval *controller_path = NULL, *params = NULL, *action_name = NULL;
zval *action_method = 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, *r11 = NULL, *r12 = NULL, *r13 = NULL;
zval *r14 = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL;
zval *t7 = NULL, *t8 = NULL, *t9 = NULL, *t10 = NULL;
zval *c0 = NULL, *c1 = NULL, *c2 = NULL;
zval *i0 = NULL;
zval *a0 = NULL, *a1 = NULL;
zval *p5[] = { NULL, NULL, NULL, NULL, NULL };
int eval_int;
zend_class_entry *ce0;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &request, &response, &view, &model) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!view) {
PHALCON_INIT_VAR(view);
ZVAL_NULL(view);
}
if (!model) {
PHALCON_INIT_VAR(model);
ZVAL_NULL(model);
}
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, "_basePath", sizeof("_basePath")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(t1);
phalcon_read_property(&t1, this_ptr, "_controllersDir", sizeof("_controllersDir")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CONCAT_VV(r0, t0, t1);
PHALCON_CPY_WRT(controllers_dir, r0);
PHALCON_INIT_VAR(value);
ZVAL_NULL(value);
PHALCON_INIT_VAR(controller);
ZVAL_NULL(controller);
PHALCON_INIT_VAR(number_dispatches);
ZVAL_LONG(number_dispatches, 0);
phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 0 TSRMLS_CC);
ws_e10f_0:
PHALCON_INIT_VAR(t2);
phalcon_read_property(&t2, this_ptr, "_finished", sizeof("_finished")-1, PHALCON_NOISY TSRMLS_CC);
if (zend_is_true(t2)) {
goto we_e10f_0;
}
phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 1 TSRMLS_CC);
PHALCON_INIT_VAR(t3);
phalcon_read_property(&t3, this_ptr, "_controllerName", sizeof("_controllerName")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(controller_name, t3);
if (!zend_is_true(controller_name)) {
PHALCON_INIT_VAR(t4);
phalcon_read_property(&t4, this_ptr, "_defaultController", sizeof("_defaultController")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(controller_name, t4);
phalcon_update_property_zval(this_ptr, "_controllerName", strlen("_controllerName"), controller_name TSRMLS_CC);
}
PHALCON_INIT_VAR(t5);
phalcon_read_property(&t5, this_ptr, "_controllers", sizeof("_controllers")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(controllers, t5);
PHALCON_INIT_VAR(r1);
PHALCON_INIT_VAR(r2);
PHALCON_CALL_STATIC_PARAMS_1(r2, "phalcon_text", "camelize", controller_name);
PHALCON_CONCAT_VS(r1, r2, "Controller");
PHALCON_CPY_WRT(controller_class, r1);
eval_int = phalcon_array_isset(controllers, controller_class);
if (!eval_int) {
PHALCON_INIT_VAR(r3);
PHALCON_INIT_VAR(c0);
ZVAL_BOOL(c0, 0);
PHALCON_CALL_FUNC_PARAMS_2(r3, "class_exists", controller_class, c0, 0x012);
if (!zend_is_true(r3)) {
PHALCON_INIT_VAR(r4);
PHALCON_CONCAT_VVS(r4, controllers_dir, controller_class, ".php");
//.........这里部分代码省略.........
示例5: PHP_METHOD
/**
* Handles a MVC request
*
* @param string $uri
* @return Phalcon\Http\ResponseInterface
*/
PHP_METHOD(Phalcon_Mvc_Application, handle){
zval *uri = NULL, *dependency_injector, *events_manager;
zval *event_name = NULL, *status = NULL, *service = NULL, *router, *module_name = NULL;
zval *module_object = NULL, *modules, *exception_msg = NULL;
zval *module, *class_name = NULL, *path, *module_params;
zval *implicit_view, *view, *namespace_name;
zval *controller_name = NULL, *action_name = NULL, *params = NULL;
zval *dispatcher, *controller, *returned_response = NULL;
zval *possible_response, *render_status = NULL, *response = NULL;
zval *content;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 1, &uri);
if (!uri) {
PHALCON_INIT_VAR(uri);
}
PHALCON_OBS_VAR(dependency_injector);
phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_application_exception_ce, "A dependency injection object is required to access internal services");
return;
}
PHALCON_OBS_VAR(events_manager);
phalcon_read_property_this(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC);
/**
* Call boot event, this allow the developer to perform initialization actions
*/
if (Z_TYPE_P(events_manager) == IS_OBJECT) {
PHALCON_INIT_VAR(event_name);
ZVAL_STRING(event_name, "application:boot", 1);
PHALCON_INIT_VAR(status);
phalcon_call_method_p2(status, events_manager, "fire", event_name, this_ptr);
if (PHALCON_IS_FALSE(status)) {
RETURN_MM_FALSE;
}
}
PHALCON_INIT_VAR(service);
ZVAL_STRING(service, "router", 1);
PHALCON_INIT_VAR(router);
phalcon_call_method_p1(router, dependency_injector, "getshared", service);
/**
* Handle the URI pattern (if any)
*/
phalcon_call_method_p1_noret(router, "handle", uri);
/**
* Load module config
*/
PHALCON_INIT_VAR(module_name);
phalcon_call_method(module_name, router, "getmodulename");
/**
* If the router doesn't return a valid module we use the default module
*/
if (!zend_is_true(module_name)) {
PHALCON_OBS_NVAR(module_name);
phalcon_read_property_this(&module_name, this_ptr, SL("_defaultModule"), PH_NOISY_CC);
}
PHALCON_INIT_VAR(module_object);
/**
* Process the module definition
*/
if (zend_is_true(module_name)) {
if (Z_TYPE_P(events_manager) == IS_OBJECT) {
PHALCON_INIT_NVAR(event_name);
ZVAL_STRING(event_name, "application:beforeStartModule", 1);
PHALCON_INIT_NVAR(status);
phalcon_call_method_p3(status, events_manager, "fire", event_name, this_ptr, module_name);
if (PHALCON_IS_FALSE(status)) {
RETURN_MM_FALSE;
}
}
/**
* Check if the module passed by the router is registered in the modules container
*/
PHALCON_OBS_VAR(modules);
phalcon_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);
if (!phalcon_array_isset(modules, module_name)) {
//.........这里部分代码省略.........
示例6: PHP_METHOD
/**
* Execute a reflection.
*
* @param int $height
* @param int $opacity
* @param boolean $fade_in
*/
PHP_METHOD(Phalcon_Image_Adapter_GD, _reflection) {
zval *_height, *opacity, *fade_in, height = {}, tmp = {}, reflection = {}, line = {}, image = {}, image_width = {}, image_height = {}, dst = {}, filtertype = {};
int h0, h1, tmp_opacity, int_opacity, offset;
double stepping;
phalcon_fetch_params(0, 3, 0, &_height, &opacity, &fade_in);
PHALCON_CPY_WRT_CTOR(&height, _height);
phalcon_return_property(&image, getThis(), SL("_image"));
phalcon_return_property(&image_width, getThis(), SL("_width"));
phalcon_return_property(&image_height, getThis(), SL("_height"));
if (!phalcon_get_constant(&filtertype, SL("IMG_FILTER_COLORIZE"))) {
return;
}
h0 = phalcon_get_intval(&height);
h1 = phalcon_get_intval(&image_height);
if (unlikely(h0 == 0)) {
h0 = 1;
}
tmp_opacity = phalcon_get_intval(opacity);
tmp_opacity = (int)((tmp_opacity * 127 / 100) - 127 + 0.5);
if (tmp_opacity < 0) {
tmp_opacity = -tmp_opacity;
}
if (tmp_opacity < 127) {
stepping = (127 - tmp_opacity) / h0;
} else {
stepping = 127 / h0;
}
ZVAL_DOUBLE(&height, h0 + h1);
PHALCON_CALL_METHODW(&reflection, getThis(), "_create", &image_width, &height);
ZVAL_LONG(&dst, 0);
PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &reflection, &image, &dst, &dst, &dst, &dst, &image_width, &image_height);
ZVAL_LONG(&tmp, 1);
for (offset = 0; h0 >= offset; offset++) {
zval src_y = {}, dst_y = {}, dst_opacity = {};
ZVAL_LONG(&src_y, h1 - offset - 1);
ZVAL_LONG(&dst_y, h1 + offset);
if (zend_is_true(fade_in)) {
int_opacity = (int)(tmp_opacity + (stepping * (h0 - offset)) + 0.5);
ZVAL_LONG(&dst_opacity, int_opacity);
} else {
int_opacity = (int)(tmp_opacity + (stepping * offset) + 0.5);
ZVAL_LONG(&dst_opacity, int_opacity);
}
PHALCON_CALL_METHODW(&line, getThis(), "_create", &image_width, &tmp);
PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &line, &image, &dst, &dst, &dst, &src_y, &image_width, &tmp);
PHALCON_CALL_FUNCTIONW(NULL, "imagefilter", &line, &filtertype, &dst, &dst, &dst, &dst_opacity);
PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &reflection, &line, &dst, &dst_y, &dst, &dst, &image_width, &tmp);
}
PHALCON_CALL_FUNCTIONW(NULL, "imagedestroy", &image);
phalcon_update_property_zval(getThis(), SL("_image"), &reflection);
PHALCON_CALL_FUNCTIONW(&image_width, "imagesx", &reflection);
PHALCON_CALL_FUNCTIONW(&image_height, "imagesy", &reflection);
phalcon_update_property_zval(getThis(), SL("_width"), &image_width);
phalcon_update_property_zval(getThis(), SL("_height"), &image_height);
}
示例7: PHP_METHOD
/**
* Produce the routing parameters from the rewrite information
*
* @param string $uri
*/
PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle){
zval *uri = NULL, *real_uri = NULL, *processed, *annotations_service = NULL;
zval *handlers, *controller_sufix, *scope = NULL, *prefix = NULL;
zval *dependency_injector = NULL, *service = NULL, *handler = NULL;
zval *sufixed = NULL, *handler_annotations = NULL, *class_annotations = NULL;
zval *annotations = NULL, *annotation = NULL, *method_annotations = NULL;
zval *lowercased = NULL, *collection = NULL, *method = NULL;
HashTable *ah0, *ah1, *ah2, *ah3;
HashPosition hp0, hp1, hp2, hp3;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &uri) == FAILURE) {
RETURN_MM_NULL();
}
if (!uri) {
PHALCON_INIT_VAR(uri);
}
if (!zend_is_true(uri)) {
/**
* If 'uri' isn't passed as parameter it reads $_GET['_url']
*/
PHALCON_INIT_VAR(real_uri);
PHALCON_CALL_METHOD(real_uri, this_ptr, "_getrewriteuri");
} else {
PHALCON_CPY_WRT(real_uri, uri);
}
PHALCON_OBS_VAR(processed);
phalcon_read_property(&processed, this_ptr, SL("_processed"), PH_NOISY_CC);
if (!zend_is_true(processed)) {
PHALCON_INIT_VAR(annotations_service);
PHALCON_OBS_VAR(handlers);
phalcon_read_property(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC);
PHALCON_OBS_VAR(controller_sufix);
phalcon_read_property(&controller_sufix, this_ptr, SL("_controllerSufix"), PH_NOISY_CC);
if (!phalcon_is_iterable(handlers, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_VALUE(scope);
if (Z_TYPE_P(scope) == IS_ARRAY) {
/**
* A prefix (if any) must be in position 0
*/
PHALCON_OBS_NVAR(prefix);
phalcon_array_fetch_long(&prefix, scope, 0, PH_NOISY_CC);
if (Z_TYPE_P(prefix) == IS_STRING) {
if (!phalcon_start_with(real_uri, prefix, NULL)) {
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}
}
if (Z_TYPE_P(annotations_service) != IS_OBJECT) {
PHALCON_OBS_NVAR(dependency_injector);
phalcon_read_property(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service");
return;
}
PHALCON_INIT_NVAR(service);
ZVAL_STRING(service, "annotations", 1);
PHALCON_INIT_NVAR(annotations_service);
PHALCON_CALL_METHOD_PARAMS_1(annotations_service, dependency_injector, "getshared", service);
}
/**
* The controller must be in position 1
*/
PHALCON_OBS_NVAR(handler);
phalcon_array_fetch_long(&handler, scope, 1, PH_NOISY_CC);
phalcon_update_property_null(this_ptr, SL("_routePrefix") TSRMLS_CC);
PHALCON_INIT_NVAR(sufixed);
PHALCON_CONCAT_VV(sufixed, handler, controller_sufix);
PHALCON_INIT_NVAR(handler_annotations);
PHALCON_CALL_METHOD_PARAMS_1(handler_annotations, annotations_service, "get", sufixed);
//.........这里部分代码省略.........
示例8: php_tcp_sockop_bind
static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *sock,
php_stream_xport_param *xparam)
{
char *host = NULL;
int portno, err;
long sockopts = STREAM_SOCKOP_NONE;
zval *tmpzval = NULL;
#ifdef AF_UNIX
if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {
struct sockaddr_un unix_addr;
sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGRAM, 0);
if (sock->socket == SOCK_ERR) {
if (xparam->want_errortext) {
xparam->outputs.error_text = strpprintf(0, "Failed to create unix%s socket %s",
stream->ops == &php_stream_unix_socket_ops ? "" : "datagram",
strerror(errno));
}
return -1;
}
parse_unix_address(xparam, &unix_addr);
return bind(sock->socket, (const struct sockaddr *)&unix_addr,
(socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen);
}
#endif
host = parse_ip_address(xparam, &portno);
if (host == NULL) {
return -1;
}
#ifdef IPV6_V6ONLY
if (PHP_STREAM_CONTEXT(stream)
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "ipv6_v6only")) != NULL
&& Z_TYPE_P(tmpzval) != IS_NULL
) {
sockopts |= STREAM_SOCKOP_IPV6_V6ONLY;
sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);
}
#endif
#ifdef SO_REUSEPORT
if (PHP_STREAM_CONTEXT(stream)
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_reuseport")) != NULL
&& zend_is_true(tmpzval)
) {
sockopts |= STREAM_SOCKOP_SO_REUSEPORT;
}
#endif
#ifdef SO_BROADCAST
if (stream->ops == &php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */
&& PHP_STREAM_CONTEXT(stream)
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_broadcast")) != NULL
&& zend_is_true(tmpzval)
) {
sockopts |= STREAM_SOCKOP_SO_BROADCAST;
}
#endif
sock->socket = php_network_bind_socket_to_local_addr(host, portno,
stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,
sockopts,
xparam->want_errortext ? &xparam->outputs.error_text : NULL,
&err
);
if (host) {
efree(host);
}
return sock->socket == -1 ? -1 : 0;
}
示例9: php_tcp_sockop_connect
static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_t *sock,
php_stream_xport_param *xparam)
{
char *host = NULL, *bindto = NULL;
int portno, bindport = 0;
int err = 0;
int ret;
zval *tmpzval = NULL;
long sockopts = STREAM_SOCKOP_NONE;
#ifdef AF_UNIX
if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {
struct sockaddr_un unix_addr;
sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGRAM, 0);
if (sock->socket == SOCK_ERR) {
if (xparam->want_errortext) {
xparam->outputs.error_text = strpprintf(0, "Failed to create unix socket");
}
return -1;
}
parse_unix_address(xparam, &unix_addr);
ret = php_network_connect_socket(sock->socket,
(const struct sockaddr *)&unix_addr, (socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen,
xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC, xparam->inputs.timeout,
xparam->want_errortext ? &xparam->outputs.error_text : NULL,
&err);
xparam->outputs.error_code = err;
goto out;
}
#endif
host = parse_ip_address(xparam, &portno);
if (host == NULL) {
return -1;
}
if (PHP_STREAM_CONTEXT(stream) && (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "bindto")) != NULL) {
if (Z_TYPE_P(tmpzval) != IS_STRING) {
if (xparam->want_errortext) {
xparam->outputs.error_text = strpprintf(0, "local_addr context option is not a string.");
}
efree(host);
return -1;
}
bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);
}
#ifdef SO_BROADCAST
if (stream->ops == &php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */
&& PHP_STREAM_CONTEXT(stream)
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_broadcast")) != NULL
&& zend_is_true(tmpzval)
) {
sockopts |= STREAM_SOCKOP_SO_BROADCAST;
}
#endif
if (stream->ops != &php_stream_udp_socket_ops /* TCP_NODELAY is only applicable for TCP */
#ifdef AF_UNIX
&& stream->ops != &php_stream_unix_socket_ops
&& stream->ops != &php_stream_unixdg_socket_ops
#endif
&& PHP_STREAM_CONTEXT(stream)
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "tcp_nodelay")) != NULL
&& zend_is_true(tmpzval)
) {
sockopts |= STREAM_SOCKOP_TCP_NODELAY;
}
/* Note: the test here for php_stream_udp_socket_ops is important, because we
* want the default to be TCP sockets so that the openssl extension can
* re-use this code. */
sock->socket = php_network_connect_socket_to_host(host, portno,
stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,
xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC,
xparam->inputs.timeout,
xparam->want_errortext ? &xparam->outputs.error_text : NULL,
&err,
bindto,
bindport,
sockopts
);
ret = sock->socket == -1 ? -1 : 0;
xparam->outputs.error_code = err;
if (host) {
efree(host);
}
if (bindto) {
efree(bindto);
}
//.........这里部分代码省略.........
示例10: PHP_METHOD
/**
* Sets a cookie to be sent at the end of the request
* This method overrides any cookie set before with the same name
*
* @param string $name
* @param mixed $value
* @param int $expire
* @param string $path
* @param boolean $secure
* @param string $domain
* @param boolean $httpOnly
* @return Phalcon\Http\Response\Cookies
*/
PHP_METHOD(Phalcon_Http_Response_Cookies, set){
zval *name, *value = NULL, *expire = NULL, *path = NULL, *secure = NULL, *domain = NULL;
zval *http_only = NULL, *cookies, *encryption, *dependency_injector = NULL;
zval *cookie = NULL, *registered, *service, *response = NULL;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 6, &name, &value, &expire, &path, &secure, &domain, &http_only);
if (Z_TYPE_P(name) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_http_cookie_exception_ce, "The cookie name must be string");
return;
}
if (!value) {
value = PHALCON_GLOBAL(z_null);
}
if (!expire) {
PHALCON_OBS_VAR(expire);
phalcon_read_property_this(&expire, this_ptr, SL("_expire"), PH_NOISY TSRMLS_CC);
}
if (!path) {
PHALCON_OBS_VAR(path);
phalcon_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY TSRMLS_CC);
}
if (!secure) {
PHALCON_OBS_VAR(secure);
phalcon_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY TSRMLS_CC);
}
if (!domain) {
PHALCON_OBS_VAR(domain);
phalcon_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY TSRMLS_CC);
}
if (!http_only) {
PHALCON_OBS_VAR(http_only);
phalcon_read_property_this(&http_only, this_ptr, SL("_httpOnly"), PH_NOISY TSRMLS_CC);
}
PHALCON_OBS_VAR(cookies);
phalcon_read_property_this(&cookies, this_ptr, SL("_cookies"), PH_NOISY TSRMLS_CC);
PHALCON_OBS_VAR(encryption);
phalcon_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY TSRMLS_CC);
PHALCON_CALL_METHOD(&dependency_injector, this_ptr, "getdi");
/**
* Check if the cookie needs to be updated or
*/
if (!phalcon_array_isset(cookies, name)) {
PHALCON_INIT_VAR(cookie);
object_init_ex(cookie, phalcon_http_cookie_ce);
PHALCON_CALL_METHOD(NULL, cookie, "__construct", name, value, expire, path, secure, domain, http_only);
/**
* Pass the DI to created cookies
*/
PHALCON_CALL_METHOD(NULL, cookie, "setdi", dependency_injector);
/**
* Enable encryption in the cookie
*/
if (zend_is_true(encryption)) {
PHALCON_CALL_METHOD(NULL, cookie, "useencryption", encryption);
}
phalcon_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC);
} else {
PHALCON_OBS_NVAR(cookie);
phalcon_array_fetch(&cookie, cookies, name, PH_NOISY);
/**
* Override any settings in the cookie
*/
PHALCON_CALL_METHOD(NULL, cookie, "setvalue", value);
PHALCON_CALL_METHOD(NULL, cookie, "setexpiration", expire);
PHALCON_CALL_METHOD(NULL, cookie, "setpath", path);
PHALCON_CALL_METHOD(NULL, cookie, "setsecure", secure);
PHALCON_CALL_METHOD(NULL, cookie, "setdomain", domain);
PHALCON_CALL_METHOD(NULL, cookie, "sethttponly", http_only);
}
//.........这里部分代码省略.........
示例11: PHP_METHOD
//.........这里部分代码省略.........
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("datetime") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
phalcon_array_update_string_long(&definition, SL("type"), 4, PH_SEPARATE TSRMLS_CC);
} else {
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("text") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC);
} else {
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("float") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
phalcon_array_update_string_long(&definition, SL("type"), 7, PH_SEPARATE TSRMLS_CC);
phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC);
} else {
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("enum") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC);
} else {
phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC);
}
}
}
}
}
}
}
}
}
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("(") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
PHALCON_INIT_VAR(matches);
array_init(matches);
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, "#\\(([0-9]+)(,[0-9]+)*\\)#", 1);
Z_SET_ISREF_P(matches);
PHALCON_INIT_VAR(pos);
PHALCON_CALL_FUNC_PARAMS_3(pos, "preg_match", c0, column_type, matches);
Z_UNSET_ISREF_P(matches);
if (zend_is_true(pos)) {
eval_int = phalcon_array_isset_long(matches, 1);
if (eval_int) {
PHALCON_INIT_VAR(match_one);
phalcon_array_fetch_long(&match_one, matches, 1, PH_NOISY_CC);
phalcon_array_update_string(&definition, SL("size"), &match_one, PH_COPY | PH_SEPARATE TSRMLS_CC);
}
}
}
PHALCON_INIT_VAR(pos);
phalcon_fast_strpos_str(pos, column_type, SL("unsigned") TSRMLS_CC);
if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {
phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_SEPARATE TSRMLS_CC);
}
if (!zend_is_true(old_column)) {
phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC);
} else {
phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC);
}
PHALCON_INIT_VAR(attribute);
phalcon_array_fetch_string(&attribute, field, SL("key"), PH_NOISY_CC);
if (PHALCON_COMPARE_STRING(attribute, "PRI")) {
phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC);
}
PHALCON_INIT_VAR(attribute);
phalcon_array_fetch_string(&attribute, field, SL("null"), PH_NOISY_CC);
if (PHALCON_COMPARE_STRING(attribute, "NO")) {
phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC);
}
PHALCON_INIT_VAR(attribute);
phalcon_array_fetch_string(&attribute, field, SL("extra"), PH_NOISY_CC);
if (PHALCON_COMPARE_STRING(attribute, "auto_increment")) {
phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC);
}
PHALCON_INIT_VAR(column_name);
phalcon_array_fetch_string(&column_name, field, SL("field"), PH_NOISY_CC);
PHALCON_INIT_VAR(column);
object_init_ex(column, phalcon_db_column_ce);
PHALCON_CALL_METHOD_PARAMS_2_NORETURN(column, "__construct", column_name, definition, PH_CHECK);
phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC);
PHALCON_CPY_WRT(old_column, column_name);
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_ecef_0;
fee_ecef_0:
RETURN_CTOR(columns);
}
示例12: PHP_METHOD
/**
* The meta-data is obtained by reading the column descriptions from the database information schema
*
* @param Phalcon\Mvc\ModelInterface $model
* @param Phalcon\DiInterface $dependencyInjector
* @return array
*/
PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData){
zval *model, *dependency_injector, *class_name;
zval *schema, *table, *read_connection, *exists;
zval *complete_table = NULL, *exception_message = NULL;
zval *columns, *attributes, *primary_keys, *non_primary_keys;
zval *numeric_typed, *not_null, *field_types;
zval *field_bind_types, *automatic_default;
zval *identity_field = NULL, *column = NULL, *field_name = NULL, *feature = NULL;
zval *type = NULL, *bind_type = NULL, *model_metadata;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &model, &dependency_injector);
PHALCON_INIT_VAR(class_name);
phalcon_get_class(class_name, model, 0 TSRMLS_CC);
PHALCON_INIT_VAR(schema);
phalcon_call_method(schema, model, "getschema");
PHALCON_INIT_VAR(table);
phalcon_call_method(table, model, "getsource");
/**
* Check if the mapped table exists on the database
*/
PHALCON_INIT_VAR(read_connection);
phalcon_call_method(read_connection, model, "getreadconnection");
PHALCON_INIT_VAR(exists);
phalcon_call_method_p2(exists, read_connection, "tableexists", table, schema);
if (!zend_is_true(exists)) {
if (zend_is_true(schema)) {
PHALCON_INIT_VAR(complete_table);
PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table);
} else {
PHALCON_CPY_WRT(complete_table, table);
}
/**
* The table not exists
*/
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVSV(exception_message, "Table \"", complete_table, "\" doesn't exist on database when dumping meta-data for ", class_name);
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);
return;
}
/**
* Try to describe the table
*/
PHALCON_INIT_VAR(columns);
phalcon_call_method_p2(columns, read_connection, "describecolumns", table, schema);
if (!phalcon_fast_count_ev(columns TSRMLS_CC)) {
if (zend_is_true(schema)) {
PHALCON_INIT_NVAR(complete_table);
PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table);
} else {
PHALCON_CPY_WRT(complete_table, table);
}
/**
* The table not exists
*/
PHALCON_INIT_NVAR(exception_message);
PHALCON_CONCAT_SVSV(exception_message, "Cannot obtain table columns for the mapped source \"", complete_table, "\" used in model ", class_name);
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);
return;
}
/**
* Initialize meta-data
*/
PHALCON_INIT_VAR(attributes);
array_init(attributes);
PHALCON_INIT_VAR(primary_keys);
array_init(primary_keys);
PHALCON_INIT_VAR(non_primary_keys);
array_init(non_primary_keys);
PHALCON_INIT_VAR(numeric_typed);
array_init(numeric_typed);
PHALCON_INIT_VAR(not_null);
array_init(not_null);
PHALCON_INIT_VAR(field_types);
//.........这里部分代码省略.........
示例13: PHP_METHOD
/**
* Check whether internal resource has rows to fetch
*
* @return boolean
*/
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, valid){
zval *type = NULL, *result, *row = NULL, *rows, *underscore, *empty_str;
zval *active_row, *columns_types, *column = NULL, *alias = NULL;
zval *source = NULL, *instance = NULL, *attributes = NULL, *column_map = NULL;
zval *row_model = NULL, *attribute = NULL, *column_alias = NULL, *value = NULL;
zval *model_attribute = NULL, *sql_alias = NULL, *n_alias = 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();
PHALCON_INIT_VAR(type);
phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC);
if (zend_is_true(type)) {
PHALCON_INIT_VAR(result);
phalcon_read_property(&result, this_ptr, SL("_result"), PH_NOISY_CC);
if (PHALCON_IS_NOT_FALSE(result)) {
PHALCON_INIT_VAR(row);
PHALCON_CALL_METHOD_PARAMS_1(row, result, "fetch", result, PH_NO_CHECK);
} else {
PHALCON_INIT_NVAR(row);
ZVAL_BOOL(row, 0);
}
} else {
PHALCON_INIT_VAR(rows);
phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC);
Z_SET_ISREF_P(rows);
PHALCON_INIT_NVAR(row);
PHALCON_CALL_FUNC_PARAMS_1(row, "current", rows);
Z_UNSET_ISREF_P(rows);
if (zend_is_true(row)) {
Z_SET_ISREF_P(rows);
PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows);
Z_UNSET_ISREF_P(rows);
}
}
if (PHALCON_IS_NOT_FALSE(row)) {
PHALCON_INIT_VAR(underscore);
ZVAL_STRING(underscore, "_", 1);
PHALCON_INIT_VAR(empty_str);
ZVAL_STRING(empty_str, "", 1);
PHALCON_INIT_VAR(active_row);
object_init_ex(active_row, phalcon_mvc_model_row_ce);
PHALCON_INIT_VAR(columns_types);
phalcon_read_property(&columns_types, this_ptr, SL("_columnTypes"), PH_NOISY_CC);
if (!phalcon_valid_foreach(columns_types TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(columns_types);
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(alias, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(column);
PHALCON_INIT_NVAR(type);
phalcon_array_fetch_string(&type, column, SL("type"), PH_NOISY_CC);
if (PHALCON_COMPARE_STRING(type, "object")) {
/**
* Object columns are assigned column by column
*/
PHALCON_INIT_NVAR(source);
phalcon_array_fetch_string(&source, column, SL("column"), PH_NOISY_CC);
PHALCON_INIT_NVAR(instance);
phalcon_array_fetch_string(&instance, column, SL("instance"), PH_NOISY_CC);
PHALCON_INIT_NVAR(attributes);
phalcon_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY_CC);
PHALCON_INIT_NVAR(column_map);
phalcon_array_fetch_string(&column_map, column, SL("columnMap"), PH_NOISY_CC);
/**
* Assign the values from the _source_attribute notation to its real column name
*/
//.........这里部分代码省略.........
示例14: pgsql_stmt_param_hook
//.........这里部分代码省略.........
zend_hash_num_elements(stmt->bound_param_map),
sizeof(char*));
S->param_lengths = ecalloc(
zend_hash_num_elements(stmt->bound_param_map),
sizeof(int));
S->param_formats = ecalloc(
zend_hash_num_elements(stmt->bound_param_map),
sizeof(int));
S->param_types = ecalloc(
zend_hash_num_elements(stmt->bound_param_map),
sizeof(Oid));
}
if (param->paramno >= 0) {
zval *parameter;
/*
if (param->paramno >= zend_hash_num_elements(stmt->bound_params)) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
return 0;
}
*/
if (Z_ISREF(param->parameter)) {
parameter = Z_REFVAL(param->parameter);
} else {
parameter = ¶m->parameter;
}
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB &&
Z_TYPE_P(parameter) == IS_RESOURCE) {
php_stream *stm;
php_stream_from_zval_no_verify(stm, parameter);
if (stm) {
if (php_stream_is(stm, &pdo_pgsql_lob_stream_ops)) {
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stm->abstract;
pdo_pgsql_bound_param *P = param->driver_data;
if (P == NULL) {
P = ecalloc(1, sizeof(*P));
param->driver_data = P;
}
P->oid = htonl(self->oid);
S->param_values[param->paramno] = (char*)&P->oid;
S->param_lengths[param->paramno] = sizeof(P->oid);
S->param_formats[param->paramno] = 1;
S->param_types[param->paramno] = OIDOID;
return 1;
} else {
zend_string *str = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
if (str != NULL) {
//??SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
ZVAL_STR(parameter, str);
} else {
ZVAL_EMPTY_STRING(parameter);
}
}
} else {
/* expected a stream resource */
pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");
return 0;
}
}
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL ||
Z_TYPE_P(parameter) == IS_NULL) {
S->param_values[param->paramno] = NULL;
S->param_lengths[param->paramno] = 0;
} else if (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE) {
S->param_values[param->paramno] = Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f";
S->param_lengths[param->paramno] = 1;
S->param_formats[param->paramno] = 0;
} else {
//SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
convert_to_string_ex(parameter);
S->param_values[param->paramno] = Z_STRVAL_P(parameter);
S->param_lengths[param->paramno] = Z_STRLEN_P(parameter);
S->param_formats[param->paramno] = 0;
}
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) {
S->param_types[param->paramno] = 0;
S->param_formats[param->paramno] = 1;
} else {
S->param_types[param->paramno] = 0;
}
}
break;
}
} else if (param->is_param) {
/* We need to manually convert to a pg native boolean value */
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL &&
((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
const char *s = zend_is_true(¶m->parameter) ? "t" : "f";
param->param_type = PDO_PARAM_STR;
zval_ptr_dtor(¶m->parameter);
ZVAL_STRINGL(¶m->parameter, s, 1);
}
}
return 1;
}
示例15: PHP_METHOD
/**
* Stores cached content into the file backend and stops the frontend
*
* @param int|string $keyName
* @param string $content
* @param long $lifetime
* @param boolean $stopBuffer
*/
PHP_METHOD(Phalcon_Cache_Backend_File, save){
zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *last_key = NULL, *prefix, *frontend, *options, *cache_dir;
zval *cache_file, *cached_content = NULL, *prepared_content;
zval *status, *is_buffering;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer);
if (!key_name) {
PHALCON_INIT_VAR(key_name);
}
if (!content) {
PHALCON_INIT_VAR(content);
}
if (!lifetime) {
PHALCON_INIT_VAR(lifetime);
}
if (!stop_buffer) {
PHALCON_INIT_VAR(stop_buffer);
ZVAL_BOOL(stop_buffer, 1);
}
if (Z_TYPE_P(key_name) == IS_NULL) {
PHALCON_OBS_VAR(last_key);
phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC);
} else {
PHALCON_OBS_VAR(prefix);
phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC);
PHALCON_INIT_NVAR(last_key);
PHALCON_CONCAT_VV(last_key, prefix, key_name);
}
if (!zend_is_true(last_key)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");
return;
}
PHALCON_OBS_VAR(frontend);
phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
PHALCON_OBS_VAR(options);
phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC);
PHALCON_OBS_VAR(cache_dir);
phalcon_array_fetch_string(&cache_dir, options, SL("cacheDir"), PH_NOISY);
PHALCON_INIT_VAR(cache_file);
PHALCON_CONCAT_VV(cache_file, cache_dir, last_key);
if (!zend_is_true(content)) {
PHALCON_INIT_VAR(cached_content);
phalcon_call_method(cached_content, frontend, "getcontent");
} else {
PHALCON_CPY_WRT(cached_content, content);
}
PHALCON_INIT_VAR(prepared_content);
phalcon_call_method_p1(prepared_content, frontend, "beforestore", cached_content);
/**
* We use file_put_contents to respect open-base-dir directive
*/
PHALCON_INIT_VAR(status);
phalcon_file_put_contents(status, cache_file, prepared_content TSRMLS_CC);
if (PHALCON_IS_FALSE(status)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cache directory can't be written");
return;
}
PHALCON_INIT_VAR(is_buffering);
phalcon_call_method(is_buffering, frontend, "isbuffering");
if (PHALCON_IS_TRUE(stop_buffer)) {
phalcon_call_method_noret(frontend, "stop");
}
if (PHALCON_IS_TRUE(is_buffering)) {
zend_print_zval(cached_content, 0);
}
phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
PHALCON_MM_RESTORE();
}