/** * Check whether resource exist in the resources list * * @param string $resourceName * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, isResource){ zval *resource_name, *resources_names, *is_resource = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &resource_name) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(resources_names); phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(resources_names, resource_name)); PHALCON_CPY_WRT(is_resource, r0); RETURN_NCTOR(is_resource); }
/** * Phalcon_Translate_Adapter_Array constructor * * @param array $data */ PHP_METHOD(Phalcon_Translate_Adapter_Array, __construct){ zval *options = NULL, *data = NULL; zval *r0 = NULL; zval *i0 = NULL, *i1 = NULL; zval *c0 = NULL, *c1 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &options) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } eval_int = phalcon_array_isset_string(options, "content", strlen("content")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r0); phalcon_array_fetch_string(&r0, options, "content", strlen("content"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(data, r0); if (Z_TYPE_P(data) != IS_ARRAY) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_translate_exception_ce); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "Translation data must be an array", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", c0, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } } else { PHALCON_ALLOC_ZVAL_MM(i1); object_init_ex(i1, phalcon_translate_exception_ce); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, "Translation content was not provided", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i1, "__construct", c1, PHALCON_CHECK); phalcon_throw_exception(i1 TSRMLS_CC); return; } phalcon_update_property_zval(this_ptr, "_traslate", strlen("_traslate"), data TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Returns the translation related to the given key * * @param string $index * @param array $placeholders * @param string $domain * @return string */ PHP_METHOD(Phalcon_Translate_Adapter_Gettext, query){ zval *index, *placeholders = NULL, *domain = NULL; zval *translation, *key = NULL, *value = NULL, *key_placeholder = NULL, *replaced = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *msgstr; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 2, &index, &placeholders, &domain); if (!domain) { msgstr = gettext(Z_STRVAL_P(index)); } else { msgstr = dgettext(Z_STRVAL_P(domain), Z_STRVAL_P(index)); } PHALCON_INIT_VAR(translation); ZVAL_STRING(translation, msgstr, 1); if (placeholders && Z_TYPE_P(placeholders) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(placeholders))) { phalcon_is_iterable(placeholders, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HKEY(key, ah0, hp0); PHALCON_GET_HVALUE(value); PHALCON_INIT_NVAR(key_placeholder); PHALCON_CONCAT_SVS(key_placeholder, "%", key, "%"); PHALCON_INIT_NVAR(replaced); phalcon_fast_str_replace(replaced, key_placeholder, value, translation); PHALCON_CPY_WRT(translation, replaced); zend_hash_move_forward_ex(ah0, &hp0); } } RETURN_CTOR(translation); }
/** * 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(); }
/** * Handles user-defined error * * @param int $severity * @param string $message * @param string $file * @param string $line * @param array $context * @return boolean */ PHP_METHOD(Phalcon_Debug, onUserDefinedError){ zval *severity, *message, *file = NULL, *line = NULL, *context = NULL, *e, *previous = NULL, *exception; zend_class_entry *default_exception_ce; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 3, &severity, &message, &file, &line, &context); if (!file) { file = PHALCON_GLOBAL(z_null); } if (!line) { line = PHALCON_GLOBAL(z_null); } if (context && Z_TYPE_P(context) == IS_ARRAY) { if ( phalcon_array_isset_string_fetch(&e, context, SS("e")) && Z_TYPE_P(e) == IS_OBJECT && instanceof_function_ex(Z_OBJCE_P(e), zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC) ) { PHALCON_CPY_WRT(previous, e); } else { previous = PHALCON_GLOBAL(z_null); } } else { previous = PHALCON_GLOBAL(z_null); } default_exception_ce = zend_get_error_exception(TSRMLS_C); ALLOC_INIT_ZVAL(exception); object_init_ex(exception, default_exception_ce); PHALCON_CALL_METHOD(NULL, exception, "__construct", message, PHALCON_GLOBAL(z_zero), severity, file, line, previous); zend_throw_exception_object(exception TSRMLS_CC); RETURN_MM_TRUE; }
/** * Dumps the complete result of a query into an array * * @param string $sqlQuery * @param int $fetchMode * @return array */ PHP_METHOD(Phalcon_Db, fetchAll){ zval *sql_query = NULL, *fetch_mode = NULL, *results = NULL, *result = NULL; zval *row = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &sql_query, &fetch_mode) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!fetch_mode) { PHALCON_ALLOC_ZVAL_MM(fetch_mode); ZVAL_LONG(fetch_mode, 2); } PHALCON_INIT_VAR(results); array_init(results); PHALCON_INIT_VAR(result); PHALCON_CALL_METHOD_PARAMS_1(result, this_ptr, "query", sql_query, PH_NO_CHECK); if (Z_TYPE_P(result) == IS_OBJECT) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", fetch_mode, PH_NO_CHECK); ph_cycle_start_0: PHALCON_INIT_VAR(r0); PHALCON_CALL_METHOD(r0, result, "fetcharray", PH_NO_CHECK); PHALCON_CPY_WRT(row, r0); if (!zend_is_true(row)) { goto ph_cycle_end_0; } phalcon_array_append(&results, row, PH_SEPARATE TSRMLS_CC); goto ph_cycle_start_0; ph_cycle_end_0: if(0){} } RETURN_CTOR(results); }
/** * Choose a view different to render than last-controller/last-action * * <code> * class ProductsController extends Phalcon\Mvc\Controller * { * * public function saveAction() * { * * //Do some save stuff... * * //Then show the list view * $this->view->pick("products/list"); * } * } * </code> * * @param string $renderView */ PHP_METHOD(Phalcon_Mvc_View, pick){ zval *render_view = NULL, *separator = NULL, *pick_view = NULL, *layout = NULL; zval *have_separator = NULL, *parts = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &render_view) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(separator); ZVAL_STRING(separator, "/", 1); if (Z_TYPE_P(render_view) == IS_ARRAY) { PHALCON_CPY_WRT(pick_view, render_view); } else { PHALCON_INIT_VAR(layout); ZVAL_NULL(layout); PHALCON_INIT_VAR(have_separator); phalcon_fast_strpos(have_separator, render_view, separator TSRMLS_CC); if (Z_TYPE_P(have_separator) != IS_BOOL || (Z_TYPE_P(have_separator) == IS_BOOL && Z_BVAL_P(have_separator))) { PHALCON_INIT_VAR(parts); phalcon_fast_explode(parts, separator, render_view TSRMLS_CC); PHALCON_INIT_VAR(layout); phalcon_array_fetch_long(&layout, parts, 0, PH_NOISY_CC); } PHALCON_INIT_VAR(pick_view); array_init(pick_view); phalcon_array_append(&pick_view, render_view, PH_SEPARATE TSRMLS_CC); if (Z_TYPE_P(layout) != IS_NULL) { phalcon_array_append(&pick_view, layout, PH_SEPARATE TSRMLS_CC); } } phalcon_update_property_zval(this_ptr, SL("_pickView"), pick_view TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Adds a column to a table * * @param string $tableName * @param string $schemaName * @param Phalcon_Db_Column $column * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, addColumn){ zval *table_name = NULL, *schema_name = NULL, *column = NULL, *sql = NULL; zval *r0 = NULL, *r1 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &table_name, &schema_name, &column) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_3(r0, "phalcon_db_dialect_mysql", "addcolumn", table_name, schema_name, column); PHALCON_CPY_WRT(sql, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_METHOD_PARAMS_1(r1, this_ptr, "query", sql, PHALCON_NO_CHECK); RETURN_DZVAL(r1); }
PHP_METHOD(Phalcon_Internal_TestTemp, e10a){ zval *a = NULL; zval *a0 = NULL; zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(a, a0); PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, "LOL", 1); phalcon_array_update_long(&a, 0, &t0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_INIT_VAR(t1); ZVAL_LONG(t1, 0); phalcon_array_update_string(&a, "LOL", strlen("LOL"), &t1, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); PHALCON_RETURN_CTOR(a); }
/** * Sends arbitrary text to a related logger in the instance * * @param string $sqlStatement * @param int $type */ PHP_METHOD(Phalcon_Db, log){ zval *sql_statement = NULL, *type = NULL, *logger = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql_statement, &type) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_logger", sizeof("_logger")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(logger, t0); if (zend_is_true(logger)) { PHALCON_CALL_METHOD_PARAMS_2_NORETURN(logger, "log", sql_statement, type, PHALCON_NO_CHECK); } PHALCON_MM_RESTORE(); }
/** * Gets HTTP user agent used to made the request * * @return string */ PHP_METHOD(Phalcon_Http_Request, getUserAgent){ zval *server = NULL, *user_agent = NULL; zval *g0 = NULL; int eval_int; PHALCON_MM_GROW(); phalcon_get_global(&g0, SL("_SERVER")+1 TSRMLS_CC); PHALCON_CPY_WRT(server, g0); eval_int = phalcon_array_isset_string(server, SL("HTTP_USER_AGENT")+1); if (eval_int) { PHALCON_INIT_VAR(user_agent); phalcon_array_fetch_string(&user_agent, server, SL("HTTP_USER_AGENT"), PH_NOISY_CC); } else { PHALCON_INIT_VAR(user_agent); ZVAL_STRING(user_agent, "", 1); } RETURN_CCTOR(user_agent); }
/** * * @param string $session_id optional, session id * * @return boolean */ PHP_METHOD(Phalcon_Session_Adapter_Memcache, destroy){ zval *_sid = NULL, sid = {}, *memcache; phalcon_fetch_params(0, 0, 1, &_sid); if (!_sid) { PHALCON_CALL_SELFW(&sid, "getid"); } else { PHALCON_CPY_WRT(&sid, _sid); } memcache = phalcon_read_property(getThis(), SL("_memcache"), PH_NOISY); if (Z_TYPE_P(memcache) == IS_OBJECT) { PHALCON_RETURN_CALL_METHODW(memcache, "delete", &sid); return; } else { RETURN_FALSE; } }
/** * Get instance of model query * * @param string $modelName * @param array $data * @return Phalcon_Model_Query $query */ PHP_METHOD(Phalcon_Model_Query, fromInput){ zval *model_name = NULL, *data = NULL, *query = NULL; zval *i0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model_name, &data) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_model_query_ce); PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); PHALCON_CPY_WRT(query, i0); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(query, "from", model_name, PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(query, "setinputdata", data, PHALCON_NO_CHECK); PHALCON_RETURN_CTOR(query); }
/** * Checks whether request include attached files * * @return boolean */ PHP_METHOD(Phalcon_Http_Request, hasFiles){ zval *files = NULL, *number_files = NULL, *has_files = NULL; zval *g0 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); phalcon_get_global(&g0, SL("_FILES")+1 TSRMLS_CC); PHALCON_CPY_WRT(files, g0); PHALCON_INIT_VAR(number_files); phalcon_fast_count(number_files, g0 TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 0); PHALCON_INIT_VAR(has_files); is_smaller_function(has_files, t0, number_files TSRMLS_CC); RETURN_NCTOR(has_files); }
/** * Get rewrite info * * @return string */ PHP_METHOD(Phalcon_Mvc_Router, _getRewriteUri){ zval *get = NULL; zval *g0 = NULL; zval *r0 = NULL; int eval_int; PHALCON_MM_GROW(); phalcon_get_global(&g0, SL("_GET")+1 TSRMLS_CC); PHALCON_CPY_WRT(get, g0); eval_int = phalcon_array_isset_string(get, SL("_url")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r0); phalcon_array_fetch_string(&r0, get, SL("_url"), PH_NOISY_CC); RETURN_CCTOR(r0); } PHALCON_MM_RESTORE(); RETURN_NULL(); }
/** * Check whether a model is already initialized * * @param string $modelName * @return bool */ PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized){ zval *model_name, *initialized, *lowercased; zval *is_intitialized = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &model_name); PHALCON_OBS_VAR(initialized); phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); PHALCON_INIT_VAR(lowercased); phalcon_fast_strtolower(lowercased, model_name); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(initialized, lowercased)); PHALCON_CPY_WRT(is_intitialized, r0); RETURN_NCTOR(is_intitialized); }
/** * Gets HTTP method which request has been made * * @return string */ PHP_METHOD(Phalcon_Http_Request, getMethod){ zval *server = NULL, *request_method = NULL; zval *g0 = NULL; int eval_int; PHALCON_MM_GROW(); phalcon_get_global(&g0, SL("_SERVER")+1 TSRMLS_CC); PHALCON_CPY_WRT(server, g0); eval_int = phalcon_array_isset_string(server, SL("REQUEST_METHOD")+1); if (eval_int) { PHALCON_INIT_VAR(request_method); phalcon_array_fetch_string(&request_method, server, SL("REQUEST_METHOD"), PH_NOISY_CC); } else { PHALCON_INIT_VAR(request_method); ZVAL_STRING(request_method, "", 1); } RETURN_CCTOR(request_method); }
/** * Returns insert id for the auto_increment column inserted in the last SQL statement * * @param string $table * @param string $primaryKey * @param string $sequenceName * @return int */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, lastInsertId){ zval *table = NULL, *primary_key = NULL, *sequence_name = NULL, *id_connection = NULL; zval *t0 = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzz", &table, &primary_key, &sequence_name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!table) { PHALCON_INIT_VAR(table); ZVAL_NULL(table); } if (!primary_key) { PHALCON_INIT_VAR(primary_key); ZVAL_NULL(primary_key); } if (!sequence_name) { PHALCON_INIT_VAR(sequence_name); ZVAL_NULL(sequence_name); } PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_idConnection"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(id_connection, t0); if (!zend_is_true(id_connection)) { PHALCON_MM_RESTORE(); RETURN_FALSE; } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_FUNC_PARAMS_1(r0, "mysqli_insert_id", id_connection); RETURN_DZVAL(r0); }
PHP_METHOD(Phalcon_Http_Response, setFileToSend){ zval *file_path, *attachment_name = NULL, *base_path = NULL; zval *headers, *content_description, *content_disposition; zval *content_transfer; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &file_path, &attachment_name); if (!attachment_name) { PHALCON_INIT_VAR(attachment_name); } if (Z_TYPE_P(attachment_name) != IS_STRING) { PHALCON_INIT_VAR(base_path); PHALCON_CALL_FUNC_PARAMS_1(base_path, "basename", file_path); } else { PHALCON_CPY_WRT(base_path, attachment_name); } PHALCON_INIT_VAR(headers); PHALCON_CALL_METHOD(headers, this_ptr, "getheaders"); PHALCON_INIT_VAR(content_description); ZVAL_STRING(content_description, "Content-Description: File Transfer", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(headers, "setraw", content_description); PHALCON_INIT_VAR(content_disposition); PHALCON_CONCAT_SV(content_disposition, "Content-Disposition: attachment; filename=", base_path); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(headers, "setraw", content_disposition); PHALCON_INIT_VAR(content_transfer); ZVAL_STRING(content_transfer, "Content-Transfer-Encoding: binary", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(headers, "setraw", content_transfer); phalcon_update_property_this(this_ptr, SL("_file"), file_path TSRMLS_CC); RETURN_THIS(); }
/** * Closes active connection returning success. Phalcon automatically closes and destroys active connections within Phalcon_Db_Pool * * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Mysql, close){ zval *id_connection = NULL, *success = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_idConnection"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(id_connection, t0); if (zend_is_true(id_connection)) { PHALCON_INIT_VAR(success); PHALCON_CALL_FUNC_PARAMS_1(success, "mysqli_close", id_connection); phalcon_update_property_null(this_ptr, SL("_idConnection") TSRMLS_CC); RETURN_CHECK_CTOR(success); } else { PHALCON_MM_RESTORE(); RETURN_TRUE; } PHALCON_MM_RESTORE(); }
/** * Phalcon_Translate constructor * * @param string $adapter * @param array $options */ PHP_METHOD(Phalcon_Translate, __construct){ zval *adapter = NULL, *options = NULL, *adapter_class = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; zval *i0 = NULL, *i1 = NULL; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &adapter, &options) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CONCAT_SV(r0, "Phalcon_Translate_Adapter_", adapter); PHALCON_CPY_WRT(adapter_class, r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "class_exists", adapter_class); if (!zend_is_true(r1)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_translate_exception_ce); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CONCAT_SVS(r2, "No existe el adaptador \"", adapter, "\""); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r2, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } ce0 = phalcon_fetch_class(adapter_class TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(i1); object_init_ex(i1, ce0); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i1, "__construct", options, PHALCON_CHECK); phalcon_update_property_zval(this_ptr, SL("_adapter"), i1 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Add a model to take part of the query * *<code> * $builder->addFrom('Robots', 'r'); *</code> * * @param string $model * @param string $alias * @return Phalcon\Mvc\Model\Query\Builder */ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, addFrom){ zval *model, *alias = NULL, *models = NULL, *current_model = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &model, &alias) == FAILURE) { RETURN_MM_NULL(); } if (!alias) { PHALCON_INIT_VAR(alias); } PHALCON_OBS_VAR(models); phalcon_read_property(&models, this_ptr, SL("_models"), PH_NOISY_CC); if (Z_TYPE_P(models) != IS_ARRAY) { if (Z_TYPE_P(models) != IS_NULL) { PHALCON_CPY_WRT(current_model, models); PHALCON_INIT_NVAR(models); array_init(models); phalcon_array_append(&models, current_model, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_NVAR(models); array_init(models); } } if (Z_TYPE_P(alias) == IS_STRING) { phalcon_array_update_zval(&models, alias, &model, PH_COPY | PH_SEPARATE TSRMLS_CC); } else { phalcon_array_append(&models, model, PH_SEPARATE TSRMLS_CC); } phalcon_update_property_zval(this_ptr, SL("_models"), models TSRMLS_CC); RETURN_THIS(); }
/** * Gets active server name * * @return string */ PHP_METHOD(Phalcon_Http_Request, getServerName){ zval *server = NULL, *server_name = NULL; zval *g0 = NULL; int eval_int; PHALCON_MM_GROW(); phalcon_get_global(&g0, SL("_SERVER")+1 TSRMLS_CC); PHALCON_CPY_WRT(server, g0); eval_int = phalcon_array_isset_string(server, SL("SERVER_NAME")+1); if (eval_int) { PHALCON_INIT_VAR(server_name); phalcon_array_fetch_string(&server_name, server, SL("SERVER_NAME"), PH_NOISY_CC); RETURN_CCTOR(server_name); } PHALCON_INIT_VAR(server_name); ZVAL_STRING(server_name, "localhost", 1); RETURN_CCTOR(server_name); }
/** * Rolls back the transaction * * @param string $rollbackMessage * @param Phalcon\Mvc\ModelInterface $rollbackRecord * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback){ zval *message = NULL, *_rollback_record = NULL, *rollback_code = NULL, rollback_record = {}, rollback_message = {}, manager = {}, connection = {}, success = {}, i0 = {}; phalcon_fetch_params(0, 0, 4, &message, &rollback_record, &rollback_code); if (!message || !zend_is_true(message)) { ZVAL_STRING(&rollback_message, "Transaction aborted"); } else { PHALCON_CPY_WRT(&rollback_message, message); } if (_rollback_record && Z_TYPE_P(_rollback_record) != IS_OBJECT) { phalcon_update_property_zval(getThis(), SL("_rollbackRecord"), _rollback_record); } phalcon_read_property(&rollback_record, getThis(), SL("_rollbackRecord"), PH_NOISY); if (!rollback_code) { rollback_code = &PHALCON_GLOBAL(z_zero); } phalcon_read_property(&manager, getThis(), SL("_manager"), PH_NOISY); if (Z_TYPE(manager) == IS_OBJECT) { PHALCON_CALL_METHODW(NULL, &manager, "notifyrollback", getThis()); } phalcon_read_property(&connection, getThis(), SL("_connection"), PH_NOISY); PHALCON_CALL_METHODW(&success, &connection, "rollback"); if (zend_is_true(&success)) { object_init_ex(&i0, phalcon_mvc_model_transaction_failed_ce); PHALCON_CALL_METHODW(NULL, &i0, "__construct", &rollback_message, &rollback_record, rollback_code); phalcon_throw_exception(&i0); } RETURN_CTOR(&success); }
/** * Phalcon\Cache\Backend\Xcache constructor * * @param Phalcon\Cache\FrontendInterface $frontend * @param array $options */ PHP_METHOD(Phalcon_Cache_Backend_Xcache, __construct){ zval *frontend, *_options = NULL, options = {}; phalcon_fetch_params(0, 1, 1, &frontend, &_options); if (!_options) { array_init(&options); } else { if (Z_TYPE_P(_options) != IS_ARRAY) { array_init(&options); } else { PHALCON_CPY_WRT(&options, _options); } } if (!phalcon_array_isset_str(&options, SL("statsKey"))) { phalcon_array_update_str_str(&options, SL("statsKey"), SL("_PHCX"), PH_COPY); } PHALCON_CALL_PARENTW(NULL, phalcon_cache_backend_xcache_ce, getThis(), "__construct", frontend, &options); }
/** * Gets active server address IP * * @return string */ PHP_METHOD(Phalcon_Http_Request, getServerAddress){ zval *server = NULL, *_SERVER, *server_addr = NULL, *localhost; PHALCON_MM_GROW(); phalcon_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); PHALCON_CPY_WRT(server, _SERVER); if (phalcon_array_isset_string(server, SS("SERVER_ADDR"))) { PHALCON_OBS_VAR(server_addr); phalcon_array_fetch_string(&server_addr, server, SL("SERVER_ADDR"), PH_NOISY_CC); RETURN_CCTOR(server_addr); } PHALCON_INIT_VAR(localhost); ZVAL_STRING(localhost, "localhost", 1); PHALCON_INIT_NVAR(server_addr); PHALCON_CALL_FUNC_PARAMS_1(server_addr, "gethostbyname", localhost); RETURN_CCTOR(server_addr); }
/** * Serializing a resultset will dump all related rows into a big array * * @return string */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize){ zval *records, *valid = NULL, *current = NULL, *cache, *data, *serialized; zval *r0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(records); array_init(records); PHALCON_CALL_METHOD_NORETURN(this_ptr, "rewind", PH_NO_CHECK); ph_cycle_start_0: PHALCON_INIT_NVAR(r0); PHALCON_CALL_METHOD(r0, this_ptr, "valid", PH_NO_CHECK); PHALCON_CPY_WRT(valid, r0); if (PHALCON_IS_NOT_TRUE(valid)) { goto ph_cycle_end_0; } PHALCON_INIT_NVAR(current); PHALCON_CALL_METHOD(current, this_ptr, "current", PH_NO_CHECK); phalcon_array_append(&records, current, PH_SEPARATE TSRMLS_CC); PHALCON_CALL_METHOD_NORETURN(this_ptr, "next", PH_NO_CHECK); goto ph_cycle_start_0; ph_cycle_end_0: PHALCON_INIT_VAR(cache); phalcon_read_property(&cache, this_ptr, SL("_cache"), PH_NOISY_CC); PHALCON_INIT_VAR(data); array_init(data); phalcon_array_update_string(&data, SL("cache"), &cache, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&data, SL("rows"), &records, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(serialized); PHALCON_CALL_FUNC_PARAMS_1(serialized, "serialize", data); RETURN_CCTOR(serialized); }
/** * Appends a condition to the current conditions using a OR operator * *<code> * $builder->orWhere('name = :name: AND id > :id:'); *</code> * * @param string $conditions * @return Phalcon\Mvc\Model\Query\Builder */ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orWhere){ zval *conditions, *current_conditions, *new_conditions = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &conditions) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(current_conditions); phalcon_read_property(¤t_conditions, this_ptr, SL("_conditions"), PH_NOISY_CC); if (zend_is_true(current_conditions)) { PHALCON_INIT_VAR(new_conditions); PHALCON_CONCAT_SVSVS(new_conditions, "(", current_conditions, ") OR (", conditions, ")"); } else { PHALCON_CPY_WRT(new_conditions, current_conditions); } phalcon_update_property_zval(this_ptr, SL("_conditions"), new_conditions TSRMLS_CC); RETURN_THIS(); }
/** * Check of a model is already initialized * * @param string $modelName * @return bool */ PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized){ zval *model_name = NULL, *initialized = NULL, *is_intitialized = NULL; zval *r0 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &model_name) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(initialized); phalcon_read_property(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); eval_int = phalcon_array_isset(initialized, model_name); PHALCON_ALLOC_ZVAL_MM(r0); ZVAL_BOOL(r0, eval_int); PHALCON_CPY_WRT(is_intitialized, r0); RETURN_NCTOR(is_intitialized); }
/** * Check whether the DI contains a service by a name * * @param string $name * @return boolean */ PHP_METHOD(Phalcon_DI, has){ zval *name, *services, *is_set_service = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &name); if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service alias must be a string"); return; } PHALCON_OBS_VAR(services); phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(services, name)); PHALCON_CPY_WRT(is_set_service, r0); RETURN_NCTOR(is_set_service); }