diff --git a/build/32bits/phalcon.c b/build/32bits/phalcon.c index 11eae2693a0..f90059eb885 100644 --- a/build/32bits/phalcon.c +++ b/build/32bits/phalcon.c @@ -45722,7 +45722,7 @@ static PHP_METHOD(Phalcon_DI_Service, getParameter){ /* Update the parameter */ if ( - phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) + phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) && phalcon_array_isset_fetch(¶meter, arguments, *position) ) { RETURN_ZVAL(parameter, 1, 0); @@ -45744,7 +45744,7 @@ static PHP_METHOD(Phalcon_DI_Service, __set_state){ phalcon_fetch_params(0, 1, 0, &attributes); if ( - !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) + !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) || !phalcon_array_isset_string_fetch(&definition, attributes, SS("_definition")) || !phalcon_array_isset_string_fetch(&shared, attributes, SS("_shared")) ) { diff --git a/build/64bits/phalcon.c b/build/64bits/phalcon.c index e0019171921..6914e41e87d 100644 --- a/build/64bits/phalcon.c +++ b/build/64bits/phalcon.c @@ -45722,7 +45722,7 @@ static PHP_METHOD(Phalcon_DI_Service, getParameter){ /* Update the parameter */ if ( - phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) + phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) && phalcon_array_isset_fetch(¶meter, arguments, *position) ) { RETURN_ZVAL(parameter, 1, 0); @@ -45744,7 +45744,7 @@ static PHP_METHOD(Phalcon_DI_Service, __set_state){ phalcon_fetch_params(0, 1, 0, &attributes); if ( - !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) + !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) || !phalcon_array_isset_string_fetch(&definition, attributes, SS("_definition")) || !phalcon_array_isset_string_fetch(&shared, attributes, SS("_shared")) ) { diff --git a/build/safe/phalcon.c b/build/safe/phalcon.c index b2d7d42ebab..71315debd45 100644 --- a/build/safe/phalcon.c +++ b/build/safe/phalcon.c @@ -45722,7 +45722,7 @@ static PHP_METHOD(Phalcon_DI_Service, getParameter){ /* Update the parameter */ if ( - phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) + phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) && phalcon_array_isset_fetch(¶meter, arguments, *position) ) { RETURN_ZVAL(parameter, 1, 0); @@ -45744,7 +45744,7 @@ static PHP_METHOD(Phalcon_DI_Service, __set_state){ phalcon_fetch_params(0, 1, 0, &attributes); if ( - !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) + !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) || !phalcon_array_isset_string_fetch(&definition, attributes, SS("_definition")) || !phalcon_array_isset_string_fetch(&shared, attributes, SS("_shared")) ) { diff --git a/ext/db/result/pdo.c b/ext/db/result/pdo.c index 20243f66bd3..9778f7249c9 100644 --- a/ext/db/result/pdo.c +++ b/ext/db/result/pdo.c @@ -57,6 +57,7 @@ PHP_METHOD(Phalcon_Db_Result_Pdo, numRows); PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek); PHP_METHOD(Phalcon_Db_Result_Pdo, setFetchMode); PHP_METHOD(Phalcon_Db_Result_Pdo, getInternalResult); +PHP_METHOD(Phalcon_Db_Result_Pdo, nextRowset); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_db_result___construct, 0, 0, 2) ZEND_ARG_INFO(0, connection) @@ -76,6 +77,7 @@ static const zend_function_entry phalcon_db_result_pdo_method_entry[] = { PHP_ME(Phalcon_Db_Result_Pdo, dataSeek, arginfo_phalcon_db_resultinterface_dataseek, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, setFetchMode, arginfo_phalcon_db_resultinterface_setfetchmode, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, getInternalResult, arginfo_phalcon_db_resultinterface_getinternalresult, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Db_Result_Pdo, nextRowset, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -469,3 +471,19 @@ PHP_METHOD(Phalcon_Db_Result_Pdo, getInternalResult){ RETURN_MEMBER(this_ptr, "_pdoStatement"); } +/** + * Advances to the next rowset in a multi-rowset statement handle + * + * @return boolean + */ +PHP_METHOD(Phalcon_Db_Result_Pdo, nextRowset){ + + zval *pdo_statement; + + PHALCON_MM_GROW(); + + pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); + PHALCON_RETURN_CALL_METHOD(pdo_statement, "nextrowset"); + + RETURN_MM(); +} diff --git a/ext/di/service.c b/ext/di/service.c index 195acd6728d..c141a5d948d 100644 --- a/ext/di/service.c +++ b/ext/di/service.c @@ -520,7 +520,7 @@ PHP_METHOD(Phalcon_DI_Service, getParameter){ /* Update the parameter */ if ( - phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) + phalcon_array_isset_string_fetch(&arguments, definition, SS("arguments")) && phalcon_array_isset_fetch(¶meter, arguments, *position) ) { RETURN_ZVAL(parameter, 1, 0); @@ -553,7 +553,7 @@ PHP_METHOD(Phalcon_DI_Service, __set_state){ phalcon_fetch_params(0, 1, 0, &attributes); if ( - !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) + !phalcon_array_isset_string_fetch(&name, attributes, SS("_name")) || !phalcon_array_isset_string_fetch(&definition, attributes, SS("_definition")) || !phalcon_array_isset_string_fetch(&shared, attributes, SS("_shared")) ) { diff --git a/ext/dispatcher.c b/ext/dispatcher.c index d2861828ad0..4a8b295fcae 100644 --- a/ext/dispatcher.c +++ b/ext/dispatcher.c @@ -575,6 +575,7 @@ PHP_METHOD(Phalcon_Dispatcher, dispatch){ zval *exception = NULL; zval *dependency_injector, *events_manager, *tmp; zval *handler_suffix, *action_suffix, *namespace_name, *handler_name, *action_name; + zval *camelized_namespace = NULL; int number_dispatches = 0; PHALCON_MM_GROW(); @@ -710,7 +711,9 @@ PHP_METHOD(Phalcon_Dispatcher, dispatch){ if (phalcon_end_with_str(namespace_name, SL("\\"))) { PHALCON_CONCAT_VVV(handler_class, namespace_name, camelized_class, handler_suffix); } else { - PHALCON_CONCAT_VSVV(handler_class, namespace_name, "\\", camelized_class, handler_suffix); + PHALCON_INIT_VAR(camelized_namespace); + phalcon_camelize(camelized_namespace, namespace_name); + PHALCON_CONCAT_VSVV(handler_class, camelized_namespace, "\\", camelized_class, handler_suffix); } } else { PHALCON_CONCAT_VV(handler_class, camelized_class, handler_suffix); @@ -1097,6 +1100,7 @@ PHP_METHOD(Phalcon_Dispatcher, getHandlerClass){ zval *camelized_class = NULL; zval *handler_suffix, *namespace_name, *handler_name; + zval *camelized_namespace; PHALCON_MM_GROW(); @@ -1143,7 +1147,9 @@ PHP_METHOD(Phalcon_Dispatcher, getHandlerClass){ if (phalcon_end_with_str(namespace_name, SL("\\"))) { PHALCON_CONCAT_VVV(return_value, namespace_name, camelized_class, handler_suffix); } else { - PHALCON_CONCAT_VSVV(return_value, namespace_name, "\\", camelized_class, handler_suffix); + PHALCON_INIT_VAR(camelized_namespace); + phalcon_camelize(camelized_namespace, namespace_name); + PHALCON_CONCAT_VSVV(return_value, camelized_namespace, "\\", camelized_class, handler_suffix); } } else { PHALCON_CONCAT_VV(return_value, camelized_class, handler_suffix); diff --git a/ext/http/request/file.c b/ext/http/request/file.c index 21911991c86..3a121c994a8 100644 --- a/ext/http/request/file.c +++ b/ext/http/request/file.c @@ -21,6 +21,7 @@ #include "http/request/exception.h" #include
+#include #include "kernel/main.h" #include "kernel/memory.h" @@ -66,6 +67,7 @@ PHP_METHOD(Phalcon_Http_Request_File, getKey); PHP_METHOD(Phalcon_Http_Request_File, isUploadedFile); PHP_METHOD(Phalcon_Http_Request_File, moveTo); PHP_METHOD(Phalcon_Http_Request_File, __set_state); +PHP_METHOD(Phalcon_Http_Request_File, getExtension); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_http_request_file___construct, 0, 0, 1) ZEND_ARG_INFO(0, file) @@ -87,6 +89,7 @@ static const zend_function_entry phalcon_http_request_file_method_entry[] = { PHP_ME(Phalcon_Http_Request_File, isUploadedFile, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Http_Request_File, moveTo, arginfo_phalcon_http_request_fileinterface_moveto, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Http_Request_File, __set_state, arginfo_phalcon_http_request_file___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Http_Request_File, getExtension, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -95,7 +98,7 @@ static const zend_function_entry phalcon_http_request_file_method_entry[] = { */ PHALCON_INIT_CLASS(Phalcon_Http_Request_File){ - PHALCON_REGISTER_CLASS(Phalcon\\Http\\Request, File, http_request_file, phalcon_http_request_file_method_entry, 0); + PHALCON_REGISTER_CLASS_EX(Phalcon\\Http\\Request, File, http_request_file, spl_ce_SplFileInfo, phalcon_http_request_file_method_entry, 0); zend_declare_property_null(phalcon_http_request_file_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_tmp"), ZEND_ACC_PROTECTED TSRMLS_CC); @@ -104,6 +107,7 @@ PHALCON_INIT_CLASS(Phalcon_Http_Request_File){ zend_declare_property_null(phalcon_http_request_file_ce, SL("_real_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_error"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_key"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(phalcon_http_request_file_ce, SL("_extension"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_request_file_ce TSRMLS_CC, 1, phalcon_http_request_fileinterface_ce); @@ -118,6 +122,7 @@ PHALCON_INIT_CLASS(Phalcon_Http_Request_File){ PHP_METHOD(Phalcon_Http_Request_File, __construct){ zval *file, *name, *temp_name, *size, *type, *error, *key = NULL; + zval *constant, *extension = NULL; PHALCON_MM_GROW(); @@ -131,13 +136,22 @@ PHP_METHOD(Phalcon_Http_Request_File, __construct){ PHALCON_OBS_VAR(name); phalcon_array_fetch_string(&name, file, SL("name"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); + + PHALCON_INIT_VAR(constant); + if (zend_get_constant(SL("PATHINFO_EXTENSION"), constant TSRMLS_CC)) { + PHALCON_CALL_FUNCTION(&extension, "pathinfo", name, constant); + phalcon_update_property_this(this_ptr, SL("_extension"), extension TSRMLS_CC); + } } if (phalcon_array_isset_string(file, SS("tmp_name"))) { PHALCON_OBS_VAR(temp_name); phalcon_array_fetch_string(&temp_name, file, SL("tmp_name"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_tmp"), temp_name TSRMLS_CC); - } + } else { + PHALCON_INIT_VAR(temp_name); + ZVAL_NULL(temp_name); + } if (phalcon_array_isset_string(file, SS("size"))) { PHALCON_OBS_VAR(size); @@ -161,6 +175,8 @@ PHP_METHOD(Phalcon_Http_Request_File, __construct){ phalcon_update_property_this(this_ptr, SL("_key"), key TSRMLS_CC); } + PHALCON_CALL_PARENT(NULL, phalcon_http_request_file_ce, this_ptr, "__construct", temp_name); + PHALCON_MM_RESTORE(); } @@ -319,3 +335,14 @@ PHP_METHOD(Phalcon_Http_Request_File, __set_state) { PHALCON_CALL_METHOD(NULL, return_value, "__construct", data); PHALCON_MM_RESTORE(); } + +/** + * Returns the file extension + * + * @return string + */ +PHP_METHOD(Phalcon_Http_Request_File, getExtension){ + + + RETURN_MEMBER(this_ptr, "_extension "); +} diff --git a/ext/mvc/model/criteria.c b/ext/mvc/model/criteria.c index 767798175b4..ce2b4a6d422 100644 --- a/ext/mvc/model/criteria.c +++ b/ext/mvc/model/criteria.c @@ -312,8 +312,8 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, columns){ */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, join){ - zval *model, *conditions = NULL, *alias = NULL, *type = NULL, *join, *params; - zval *current_joins, *merged_joins = NULL; + zval *model, *conditions = NULL, *alias = NULL, *type = NULL, *new_join, *params; + zval *current_joins, *merged_joins = NULL, *new_join_array = NULL; PHALCON_MM_GROW(); @@ -331,29 +331,33 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, join){ type = PHALCON_GLOBAL(z_null); } - PHALCON_INIT_VAR(join); - array_init_size(join, 4); - phalcon_array_append(&join, model, 0); - phalcon_array_append(&join, conditions, 0); - phalcon_array_append(&join, alias, 0); - phalcon_array_append(&join, type, 0); + PHALCON_INIT_VAR(new_join); + array_init_size(new_join, 4); + phalcon_array_append(&new_join, model, 0); + phalcon_array_append(&new_join, conditions, 0); + phalcon_array_append(&new_join, alias, 0); + phalcon_array_append(&new_join, type, 0); PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset_string(params, SS("joins"))) { - + + PHALCON_INIT_VAR(new_join_array); + array_init_size(new_join_array, 1); + phalcon_array_append(&new_join_array, new_join, 0); + PHALCON_OBS_VAR(current_joins); phalcon_array_fetch_string(¤t_joins, params, SL("joins"), PH_NOISY); if (Z_TYPE_P(current_joins) == IS_ARRAY) { PHALCON_INIT_VAR(merged_joins); - phalcon_fast_array_merge(merged_joins, ¤t_joins, &join TSRMLS_CC); + phalcon_fast_array_merge(merged_joins, ¤t_joins, &new_join_array TSRMLS_CC); } else { - PHALCON_CPY_WRT(merged_joins, join); + PHALCON_CPY_WRT(merged_joins, new_join_array); } } else { PHALCON_INIT_NVAR(merged_joins); array_init_size(merged_joins, 1); - phalcon_array_append(&merged_joins, join, 0); + phalcon_array_append(&merged_joins, new_join, 0); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC); @@ -378,8 +382,8 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, join){ */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin){ - zval *model, *conditions = NULL, *alias = NULL, *type, *join, *params; - zval *current_joins, *merged_joins = NULL; + zval *model, *conditions = NULL, *alias = NULL, *type, *new_join, *params; + zval *current_joins, *merged_joins = NULL, *new_join_array = NULL; PHALCON_MM_GROW(); @@ -396,29 +400,33 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin){ PHALCON_INIT_VAR(type); ZVAL_STRING(type, "INNER", 1); - PHALCON_INIT_VAR(join); - array_init_size(join, 4); - phalcon_array_append(&join, model, 0); - phalcon_array_append(&join, conditions, 0); - phalcon_array_append(&join, alias, 0); - phalcon_array_append(&join, type, 0); + PHALCON_INIT_VAR(new_join); + array_init_size(new_join, 4); + phalcon_array_append(&new_join, model, 0); + phalcon_array_append(&new_join, conditions, 0); + phalcon_array_append(&new_join, alias, 0); + phalcon_array_append(&new_join, type, 0); PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset_string(params, SS("joins"))) { - + + PHALCON_INIT_VAR(new_join_array); + array_init_size(new_join_array, 1); + phalcon_array_append(&new_join_array, new_join, 0); + PHALCON_OBS_VAR(current_joins); phalcon_array_fetch_string(¤t_joins, params, SL("joins"), PH_NOISY); if (Z_TYPE_P(current_joins) == IS_ARRAY) { PHALCON_INIT_VAR(merged_joins); - phalcon_fast_array_merge(merged_joins, ¤t_joins, &join TSRMLS_CC); + phalcon_fast_array_merge(merged_joins, ¤t_joins, &new_join_array TSRMLS_CC); } else { - PHALCON_CPY_WRT(merged_joins, join); + PHALCON_CPY_WRT(merged_joins, new_join_array); } } else { PHALCON_INIT_NVAR(merged_joins); array_init_size(merged_joins, 1); - phalcon_array_append(&merged_joins, join, PH_SEPARATE); + phalcon_array_append(&merged_joins, new_join, PH_SEPARATE); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC); @@ -440,8 +448,8 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin){ */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin){ - zval *model, *conditions = NULL, *alias = NULL, *type, *join, *params; - zval *current_joins, *merged_joins = NULL; + zval *model, *conditions = NULL, *alias = NULL, *type, *new_join, *params; + zval *current_joins, *merged_joins = NULL, *new_join_array = NULL; PHALCON_MM_GROW(); @@ -458,29 +466,33 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin){ PHALCON_INIT_VAR(type); ZVAL_STRING(type, "LEFT", 1); - PHALCON_INIT_VAR(join); - array_init_size(join, 4); - phalcon_array_append(&join, model, 0); - phalcon_array_append(&join, conditions, 0); - phalcon_array_append(&join, alias, 0); - phalcon_array_append(&join, type, 0); + PHALCON_INIT_VAR(new_join); + array_init_size(new_join, 4); + phalcon_array_append(&new_join, model, 0); + phalcon_array_append(&new_join, conditions, 0); + phalcon_array_append(&new_join, alias, 0); + phalcon_array_append(&new_join, type, 0); PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset_string(params, SS("joins"))) { - + + PHALCON_INIT_VAR(new_join_array); + array_init_size(new_join_array, 1); + phalcon_array_append(&new_join_array, new_join, 0); + PHALCON_OBS_VAR(current_joins); phalcon_array_fetch_string(¤t_joins, params, SL("joins"), PH_NOISY); if (Z_TYPE_P(current_joins) == IS_ARRAY) { PHALCON_INIT_VAR(merged_joins); - phalcon_fast_array_merge(merged_joins, ¤t_joins, &join TSRMLS_CC); + phalcon_fast_array_merge(merged_joins, ¤t_joins, &new_join_array TSRMLS_CC); } else { - PHALCON_CPY_WRT(merged_joins, join); + PHALCON_CPY_WRT(merged_joins, new_join_array); } } else { PHALCON_INIT_NVAR(merged_joins); array_init_size(merged_joins, 1); - phalcon_array_append(&merged_joins, join, PH_SEPARATE); + phalcon_array_append(&merged_joins, new_join, PH_SEPARATE); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC); @@ -502,8 +514,8 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin){ */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin){ - zval *model, *conditions = NULL, *alias = NULL, *type, *join, *params; - zval *current_joins, *merged_joins = NULL; + zval *model, *conditions = NULL, *alias = NULL, *type, *new_join, *params; + zval *current_joins, *merged_joins = NULL, *new_join_array = NULL; PHALCON_MM_GROW(); @@ -520,29 +532,33 @@ PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin){ PHALCON_INIT_VAR(type); ZVAL_STRING(type, "RIGHT", 1); - PHALCON_INIT_VAR(join); - array_init_size(join, 4); - phalcon_array_append(&join, model, 0); - phalcon_array_append(&join, conditions, 0); - phalcon_array_append(&join, alias, 0); - phalcon_array_append(&join, type, 0); + PHALCON_INIT_VAR(new_join); + array_init_size(new_join, 4); + phalcon_array_append(&new_join, model, 0); + phalcon_array_append(&new_join, conditions, 0); + phalcon_array_append(&new_join, alias, 0); + phalcon_array_append(&new_join, type, 0); PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset_string(params, SS("joins"))) { - + + PHALCON_INIT_VAR(new_join_array); + array_init_size(new_join_array, 1); + phalcon_array_append(&new_join_array, new_join, 0); + PHALCON_OBS_VAR(current_joins); phalcon_array_fetch_string(¤t_joins, params, SL("joins"), PH_NOISY); if (Z_TYPE_P(current_joins) == IS_ARRAY) { PHALCON_INIT_VAR(merged_joins); - phalcon_fast_array_merge(merged_joins, ¤t_joins, &join TSRMLS_CC); + phalcon_fast_array_merge(merged_joins, ¤t_joins, &new_join_array TSRMLS_CC); } else { - PHALCON_CPY_WRT(merged_joins, join); + PHALCON_CPY_WRT(merged_joins, new_join_array); } } else { PHALCON_INIT_NVAR(merged_joins); array_init_size(merged_joins, 1); - phalcon_array_append(&merged_joins, join, PH_SEPARATE); + phalcon_array_append(&merged_joins, new_join, PH_SEPARATE); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC); diff --git a/ext/session/adapter.c b/ext/session/adapter.c index 6f02204a630..d4aa6d44d22 100644 --- a/ext/session/adapter.c +++ b/ext/session/adapter.c @@ -59,11 +59,16 @@ PHP_METHOD(Phalcon_Session_Adapter, destroy); PHP_METHOD(Phalcon_Session_Adapter, __get); PHP_METHOD(Phalcon_Session_Adapter, count); PHP_METHOD(Phalcon_Session_Adapter, getIterator); +PHP_METHOD(Phalcon_Session_Adapter, setId); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_adapter___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_adapter_setid, 0, 0, 1) + ZEND_ARG_INFO(0, sid) +ZEND_END_ARG_INFO() + static const zend_function_entry phalcon_session_adapter_method_entry[] = { PHP_ME(Phalcon_Session_Adapter, __construct, arginfo_phalcon_session_adapter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Session_Adapter, __destruct, arginfo___destruct, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) @@ -87,6 +92,7 @@ static const zend_function_entry phalcon_session_adapter_method_entry[] = { PHP_MALIAS(Phalcon_Session_Adapter, offsetUnset, remove, arginfo_arrayaccess_offsetunset, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Session_Adapter, count, arginfo_countable_count, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Session_Adapter, getIterator, arginfo_iteratoraggregate_getiterator, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Session_Adapter, setId, arginfo_phalcon_session_adapter_setid, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -679,3 +685,19 @@ PHP_METHOD(Phalcon_Session_Adapter, getIterator) object_init_ex(return_value, spl_ce_ArrayIterator); PHALCON_CALL_METHODW(NULL, return_value, "__construct", data); } + +/** + * Set the current session id + * + * + * $session->setId($id); + * + */ +PHP_METHOD(Phalcon_Session_Adapter, setId){ + + zval *sid; + + phalcon_fetch_params(0, 1, 0, &sid); + + RETURN_ON_FAILURE(phalcon_set_session_id(sid TSRMLS_CC)); +} diff --git a/unit-tests/ModelsCriteriaTest.php b/unit-tests/ModelsCriteriaTest.php index 4ce4aff2dbf..cefe41c1e01 100644 --- a/unit-tests/ModelsCriteriaTest.php +++ b/unit-tests/ModelsCriteriaTest.php @@ -75,6 +75,7 @@ public function testModelsMysql() $this->_executeTestsRenamed($di); $this->_executeTestsFromInput($di); $this->_executeTestIssues2131($di); + $this->_executeJoinTests($di, "mysql"); } public function testModelsPostgresql() @@ -96,6 +97,7 @@ public function testModelsPostgresql() $this->_executeTestsRenamed($di); $this->_executeTestsFromInput($di); $this->_executeTestIssues2131($di); + $this->_executeJoinTests($di, "postgresql"); } public function testModelsSQLite() @@ -117,11 +119,12 @@ public function testModelsSQLite() $this->_executeTestsRenamed($di); $this->_executeTestsFromInput($di); $this->_executeTestIssues2131($di); + $this->_executeJoinTests($di, "sqlite"); } protected function _executeTestsNormal($di) { - + //Where $personas = Personas::query()->where("estado='I'")->execute(); $people = People::find("estado='I'"); $this->assertEquals(count($personas), count($people)); @@ -144,7 +147,7 @@ protected function _executeTestsNormal($di) $somePeople = $people->getFirst(); $this->assertEquals($somePersona->cedula, $somePeople->cedula); - //Order + limit + //Where + Order + limit $personas = Personas::query() ->where("estado='A'") ->orderBy("nombres") @@ -161,7 +164,7 @@ protected function _executeTestsNormal($di) $somePeople = $people->getFirst(); $this->assertEquals($somePersona->cedula, $somePeople->cedula); - //Bind params + Limit + //Where with bind params + order + Limit $personas = Personas::query() ->where("estado=?1") ->bind(array(1 => "A")) @@ -181,7 +184,7 @@ protected function _executeTestsNormal($di) $somePeople = $people->getFirst(); $this->assertEquals($somePersona->cedula, $somePeople->cedula); - //Limit + Offset + //Where with bind params + order + limit + Offset $personas = Personas::query() ->where("estado=?1") ->bind(array(1 => "A")) @@ -201,6 +204,7 @@ protected function _executeTestsNormal($di) $somePeople = $people->getFirst(); $this->assertEquals($somePersona->cedula, $somePeople->cedula); + //Where with named bind params + order + limit $personas = Personas::query() ->where("estado=:estado:") ->bind(array("estado" => "A")) @@ -219,7 +223,59 @@ protected function _executeTestsNormal($di) $somePersona = $personas->getFirst(); $somePeople = $people->getFirst(); $this->assertEquals($somePersona->cedula, $somePeople->cedula); + } + protected function _executeJoinTests($di, $dbtype) + { + //Left join with Simple resultset + $robotparts = RobotsParts::query() + ->columns("Robots.id, Robots.name, RobotsParts.id robotpart_id") + ->leftJoin("Robots", "Robots.id = RobotsParts.robots_id") + ->execute(); + $this->assertTrue(is_object($robotparts)); + $this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Simple', $robotparts); + $this->assertNotNull($robotparts->getFirst()->id); + $this->assertNotNull($robotparts->getFirst()->name); + $this->assertNotNull($robotparts->getFirst()->robotpart_id); + + //Two left joins with Simple resultset + $robotparts = RobotsParts::query() + ->columns("RobotsParts.id, r.id robot_id, p.id part_id") + ->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r") + ->leftJoin("Parts", "p.id = RobotsParts.parts_id", "p") + ->execute(); + $this->assertTrue(is_object($robotparts)); + $this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Simple', $robotparts); + $this->assertNotNull($robotparts->getFirst()->id); + $this->assertNotNull($robotparts->getFirst()->robot_id); + $this->assertNotNull($robotparts->getFirst()->part_id); + + //Right join not supported in sqlite + if ($dbtype != "sqlite") + { + //Right join with Simple resultset + $robotparts = RobotsParts::query() + ->columns("Robots.id, Robots.name, RobotsParts.id robotpart_id") + ->rightJoin("Robots", "Robots.id = RobotsParts.robots_id") + ->execute(); + $this->assertTrue(is_object($robotparts)); + $this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Simple', $robotparts); + $this->assertNotNull($robotparts->getFirst()->id); + $this->assertNotNull($robotparts->getFirst()->name); + $this->assertNotNull($robotparts->getFirst()->robotpart_id); + + //Two right joins with Simple resultset + $robotparts = RobotsParts::query() + ->columns("RobotsParts.id, r.id robot_id, p.id part_id") + ->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r") + ->rightJoin("Parts", "p.id = RobotsParts.parts_id", "p") + ->execute(); + $this->assertTrue(is_object($robotparts)); + $this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Simple', $robotparts); + $this->assertNotNull($robotparts->getFirst()->id); + $this->assertNotNull($robotparts->getFirst()->robot_id); + $this->assertNotNull($robotparts->getFirst()->part_id); + } } protected function _executeTestsRenamed($di)