diff --git a/.travis.yml b/.travis.yml index 67a12817bfc..a0fc1516c2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: - mysql -uroot -e 'create database phalcon_test charset=utf8 collate=utf8_unicode_ci;' - mysql -uroot phalcon_test < unit-tests/schemas/mysql/phalcon_test.sql - psql -c 'create database phalcon_test;' -U postgres - - psql -U postgres phalcon_test -f unit-tests/schemas/postgresql/phalcon_test.sql + - psql -U postgres phalcon_test -q -f unit-tests/schemas/postgresql/phalcon_test.sql - chmod +x unit-tests/ci/run_script.sh script: sudo ./unit-tests/ci/run_script.sh diff --git a/dev/controller/front.c b/dev/controller/front.c index 1b69453d174..d44a9d9b279 100755 --- a/dev/controller/front.c +++ b/dev/controller/front.c @@ -193,7 +193,7 @@ PHP_METHOD(Phalcon_Controller_Front, setControllersDir){ /** * Sets models directory. Depending of your platform, always add a trailing slash or backslash - * +* * * * @param string $modelsDir @@ -710,6 +710,7 @@ PHP_METHOD(Phalcon_Controller_Front, dispatchLoop){ PHALCON_ALLOC_ZVAL_MM(r10); PHALCON_CALL_METHOD(r10, view, "getcontent", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(response, "setcontent", r10, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_NORETURN(response, "sendheaders", PHALCON_NO_CHECK); RETURN_CHECK_CTOR(response); } diff --git a/dev/db.c b/dev/db.c index bc09fb847d3..49b87e6610c 100755 --- a/dev/db.c +++ b/dev/db.c @@ -588,10 +588,10 @@ PHP_METHOD(Phalcon_Db, delete){ } /** - * Starts a transaction in the connection - * - * @return boolean - */ +* Starts a transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, begin){ zval *r0 = NULL; @@ -610,10 +610,10 @@ PHP_METHOD(Phalcon_Db, begin){ } /** - * Rollbacks the active transaction in the connection - * - * @return boolean - */ +* Rollbacks the active transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, rollback){ zval *t0 = NULL; @@ -642,10 +642,10 @@ PHP_METHOD(Phalcon_Db, rollback){ } /** - * Commits the active transaction in the connection - * - * @return boolean - */ +* Commits the active transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, commit){ zval *t0 = NULL; @@ -827,7 +827,7 @@ PHP_METHOD(Phalcon_Db, getUsername){ /** * Returns the username which has connected to the database - * +* * @return string */ PHP_METHOD(Phalcon_Db, getHostName){ @@ -861,10 +861,10 @@ PHP_METHOD(Phalcon_Db, getHostName){ */ PHP_METHOD(Phalcon_Db, _beforeQuery){ - zval *sql_statement = NULL; - zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL; + zval *sql_statement = NULL, *logger = NULL, *profiler = NULL; + zval *t0 = NULL, *t1 = NULL; zval *r0 = NULL, *r1 = NULL; - zval *c0 = NULL; + zval *c0 = NULL, *c1 = NULL; PHALCON_MM_GROW(); @@ -875,26 +875,24 @@ PHP_METHOD(Phalcon_Db, _beforeQuery){ PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_logger"), PHALCON_NOISY TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_logger"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(logger, t0); + if (zend_is_true(logger)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 1); PHALCON_CALL_METHOD_PARAMS_1(r1, this_ptr, "getconnectionid", c0, PHALCON_NO_CHECK); PHALCON_CONCAT_SVSV(r0, "[", r1, "] ", sql_statement); - PHALCON_ALLOC_ZVAL_MM(t2); - phalcon_get_class_constant(t2, phalcon_logger_ce, SL("DEBUG") TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(t1, "log", r0, t2, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(c1); + ZVAL_LONG(c1, 7); + PHALCON_CALL_METHOD_PARAMS_2_NORETURN(logger, "log", r0, c1, PHALCON_NO_CHECK); } - PHALCON_ALLOC_ZVAL_MM(t3); - phalcon_read_property(&t3, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); - if (zend_is_true(t3)) { - PHALCON_ALLOC_ZVAL_MM(t4); - phalcon_read_property(&t4, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t4, "startprofile", sql_statement, PHALCON_NO_CHECK); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(profiler, t1); + if (zend_is_true(profiler)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(profiler, "startprofile", sql_statement, PHALCON_NO_CHECK); } PHALCON_MM_RESTORE(); diff --git a/dev/db/pool.c b/dev/db/pool.c index 972c1381643..2897cfe3d7c 100755 --- a/dev/db/pool.c +++ b/dev/db/pool.c @@ -136,7 +136,7 @@ PHP_METHOD(Phalcon_Db_Pool, setDefaultDescriptor){ * * * @param boolean $newConnection - * @param boolean $renovate +* @param boolean $renovate * @return Phalcon_Db */ PHP_METHOD(Phalcon_Db_Pool, getConnection){ diff --git a/dev/db/profiler.c b/dev/db/profiler.c index 8252762dc91..ec2fc5ca2b2 100644 --- a/dev/db/profiler.c +++ b/dev/db/profiler.c @@ -162,7 +162,7 @@ PHP_METHOD(Phalcon_Db_Profiler, stopProfile){ } /** - * Returns the total number of SQL statements processed +* Returns the total number of SQL statements processed * * @return integer */ diff --git a/dev/dispatcher.c b/dev/dispatcher.c index 46ea45910e6..289bb80dde7 100755 --- a/dev/dispatcher.c +++ b/dev/dispatcher.c @@ -141,7 +141,7 @@ PHP_METHOD(Phalcon_Dispatcher, getBasePath){ /** * Sets the default controller name - * +* * @param string $controllerName */ PHP_METHOD(Phalcon_Dispatcher, setDefaultController){ @@ -162,7 +162,7 @@ PHP_METHOD(Phalcon_Dispatcher, setDefaultController){ /** * Sets the default action name - * +* * @param string $actionName */ PHP_METHOD(Phalcon_Dispatcher, setDefaultAction){ @@ -294,9 +294,9 @@ PHP_METHOD(Phalcon_Dispatcher, getParams){ /** * Set a param by its name or numeric index - * - * @param mixed $param - * @param mixed $value +* +* @param mixed $param +* @param mixed $value */ PHP_METHOD(Phalcon_Dispatcher, setParam){ @@ -320,8 +320,8 @@ PHP_METHOD(Phalcon_Dispatcher, setParam){ /** * Gets a param by its name or numeric index - * - * @param mixed $param +* +* @param mixed $param * @return mixed */ PHP_METHOD(Phalcon_Dispatcher, getParam){ @@ -760,7 +760,7 @@ PHP_METHOD(Phalcon_Dispatcher, getControllers){ } /** - * Returns last dispatched controller + * Returns the lastest dispatched controller * * @return Phalcon_Controller */ @@ -776,7 +776,7 @@ PHP_METHOD(Phalcon_Dispatcher, getLastController){ } /** - * Returns value returned by last dispacthed action + * Returns value returned by the lastest dispatched action * * @return mixed */ diff --git a/dev/flash.c b/dev/flash.c index 4b22ae7d0a7..8f3a4acad47 100755 --- a/dev/flash.c +++ b/dev/flash.c @@ -135,7 +135,7 @@ PHP_METHOD(Phalcon_Flash, error){ /** * Shows a HTML notice/information message * - * +* * * @param string $message * @param string $classes diff --git a/dev/model/base.c b/dev/model/base.c index cdfc0477194..3e34aa6e4db 100755 --- a/dev/model/base.c +++ b/dev/model/base.c @@ -32,8 +32,8 @@ #include "kernel/main.h" #include "kernel/memory.h" -#include "kernel/fcall.h" #include "kernel/object.h" +#include "kernel/fcall.h" #include "kernel/array.h" #include "kernel/operators.h" #include "kernel/concat.h" @@ -63,9 +63,9 @@ */ PHP_METHOD(Phalcon_Model_Base, __construct){ - zval *manager = NULL, *class_name = NULL; - zval *t0 = NULL, *t1 = NULL; - zval *r0 = NULL, *r1 = NULL; + zval *manager = NULL; + zval *t0 = NULL; + zval *r0 = NULL; PHALCON_MM_GROW(); @@ -77,32 +77,24 @@ PHP_METHOD(Phalcon_Model_Base, __construct){ if (!manager) { PHALCON_INIT_VAR(manager); ZVAL_NULL(manager); + } else { + PHALCON_SEPARATE_PARAM(manager); } if (!zend_is_true(manager)) { - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (!zend_is_true(manager)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), r0 TSRMLS_CC); + PHALCON_CPY_WRT(manager, r0); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); } } else { - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), manager TSRMLS_CC); - } - - PHALCON_ALLOC_ZVAL_MM(r1); - phalcon_get_class(r1, this_ptr TSRMLS_CC); - PHALCON_CPY_WRT(class_name, r1); - - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); - if (!zend_is_true(t1)) { - if (phalcon_method_exists_ex(this_ptr, SL("initialize") TSRMLS_CC) == SUCCESS) { - PHALCON_CALL_METHOD_NORETURN(this_ptr, "initialize", PHALCON_NO_CHECK); - } - phalcon_update_property_bool(this_ptr, SL("_initialized"), 1 TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); } + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(manager, "initialize", this_ptr, PHALCON_NO_CHECK); PHALCON_MM_RESTORE(); } @@ -123,7 +115,7 @@ PHP_METHOD(Phalcon_Model_Base, setManager){ RETURN_NULL(); } - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), manager TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); PHALCON_MM_RESTORE(); } @@ -138,8 +130,8 @@ PHP_METHOD(Phalcon_Model_Base, getManager){ zval *t0 = NULL; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); RETURN_CHECK_CTOR(t0); } @@ -158,8 +150,8 @@ PHP_METHOD(Phalcon_Model_Base, _connect){ phalcon_read_property(&t0, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r0, t1, "getconnection", PHALCON_NO_CHECK); phalcon_update_property_zval(this_ptr, SL("_connection"), r0 TSRMLS_CC); } @@ -181,8 +173,8 @@ PHP_METHOD(Phalcon_Model_Base, getAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -201,8 +193,8 @@ PHP_METHOD(Phalcon_Model_Base, getPrimaryKeyAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getprimarykeyattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -221,8 +213,8 @@ PHP_METHOD(Phalcon_Model_Base, getNonPrimaryKeyAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getnonprimarykeyattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -241,8 +233,8 @@ PHP_METHOD(Phalcon_Model_Base, getNotNullAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getnotnullattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -261,8 +253,8 @@ PHP_METHOD(Phalcon_Model_Base, getDataTypesNumeric){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getdatatypesnumeric", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -281,8 +273,8 @@ PHP_METHOD(Phalcon_Model_Base, getDataTypes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getdatatypes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -301,8 +293,8 @@ PHP_METHOD(Phalcon_Model_Base, getIdentityField){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getidentityfield", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -718,7 +710,7 @@ PHP_METHOD(Phalcon_Model_Base, _getOrCreateResultset){ PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_model_resultset_ce); - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i0, "__construct", model, result_data, PHALCON_CHECK); + PHALCON_CALL_METHOD_PARAMS_3_NORETURN(i0, "__construct", model, result_data, cache, PHALCON_CHECK); PHALCON_CPY_WRT(resultset, i0); if (Z_TYPE_P(cache) != IS_NULL) { PHALCON_CALL_METHOD_PARAMS_3_NORETURN(cache, "save", key, resultset, lifetime, PHALCON_NO_CHECK); @@ -811,8 +803,8 @@ PHP_METHOD(Phalcon_Model_Base, getSource){ phalcon_read_property(&t0, this_ptr, SL("_source"), PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r1); phalcon_get_class(r1, this_ptr TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_1(r0, t1, "getsource", r1, PHALCON_NO_CHECK); @@ -971,13 +963,11 @@ PHP_METHOD(Phalcon_Model_Base, dumpResult){ */ PHP_METHOD(Phalcon_Model_Base, find){ - zval *parameters = NULL, *class_name = NULL, *model = NULL, *manager = NULL; + zval *parameters = NULL, *manager = NULL, *class_name = NULL, *model = NULL; zval *connection = NULL, *params = NULL; - zval *i0 = NULL; - zval *r0 = NULL, *r1 = NULL, *r2 = NULL; + zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -991,26 +981,24 @@ PHP_METHOD(Phalcon_Model_Base, find){ ZVAL_NULL(parameters); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -1027,7 +1015,7 @@ PHP_METHOD(Phalcon_Model_Base, find){ PHALCON_CPY_WRT(params, parameters); } - PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_ALLOC_ZVAL_MM(r3); p0[0] = manager; p0[1] = model; p0[2] = connection; @@ -1035,8 +1023,8 @@ PHP_METHOD(Phalcon_Model_Base, find){ PHALCON_INIT_VAR(p0[4]); ZVAL_BOOL(p0[4], 0); - PHALCON_CALL_SELF_PARAMS(r2, this_ptr, "_getorcreateresultset", 5, p0); - RETURN_DZVAL(r2); + PHALCON_CALL_SELF_PARAMS(r3, this_ptr, "_getorcreateresultset", 5, p0); + RETURN_DZVAL(r3); } /** @@ -1049,15 +1037,13 @@ PHP_METHOD(Phalcon_Model_Base, find){ */ PHP_METHOD(Phalcon_Model_Base, findFirst){ - zval *parameters = NULL, *class_name = NULL, *model = NULL, *manager = NULL; + zval *parameters = NULL, *manager = NULL, *class_name = NULL, *model = NULL; zval *connection = NULL, *params = NULL; - zval *i0 = NULL; - zval *r0 = NULL, *r1 = NULL, *r2 = NULL; + zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *a0 = NULL, *a1 = NULL; zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; int eval_int; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -1071,26 +1057,24 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ ZVAL_NULL(parameters); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -1114,7 +1098,7 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ phalcon_array_update_string(¶ms, SL("limit"), &t0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } - PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_ALLOC_ZVAL_MM(r3); p0[0] = manager; p0[1] = model; p0[2] = connection; @@ -1122,8 +1106,8 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ PHALCON_INIT_VAR(p0[4]); ZVAL_BOOL(p0[4], 1); - PHALCON_CALL_SELF_PARAMS(r2, this_ptr, "_getorcreateresultset", 5, p0); - RETURN_DZVAL(r2); + PHALCON_CALL_SELF_PARAMS(r3, this_ptr, "_getorcreateresultset", 5, p0); + RETURN_DZVAL(r3); } /** @@ -1297,21 +1281,20 @@ PHP_METHOD(Phalcon_Model_Base, _exists){ * @param string $function * @param string $alias * @param array $parameters + * @return Phalcon_Model_Resultset */ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ - zval *function = NULL, *alias = NULL, *parameters = NULL, *class_name = NULL; - zval *model = NULL, *manager = NULL, *connection = NULL, *params = NULL, *schema = NULL; - zval *source = NULL, *table = NULL, *group_column = NULL, *select = NULL, *conditions = NULL; - zval *i0 = NULL; + zval *function = NULL, *alias = NULL, *parameters = NULL, *manager = NULL, *class_name = NULL; + zval *model = NULL, *connection = NULL, *params = NULL, *schema = NULL, *source = NULL; + zval *table = NULL, *group_column = NULL, *select = NULL, *conditions = 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, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL, *r19 = NULL, *r20 = NULL; - zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL; + zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL, *r26 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL }; int eval_int; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -1320,26 +1303,24 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ RETURN_NULL(); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -1356,26 +1337,26 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ PHALCON_CPY_WRT(params, parameters); } - PHALCON_ALLOC_ZVAL_MM(r2); - PHALCON_CALL_METHOD(r2, model, "getschema", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(schema, r2); - PHALCON_ALLOC_ZVAL_MM(r3); - PHALCON_CALL_METHOD(r3, model, "getsource", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(source, r3); + PHALCON_CALL_METHOD(r3, model, "getschema", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(schema, r3); + + PHALCON_ALLOC_ZVAL_MM(r4); + PHALCON_CALL_METHOD(r4, model, "getsource", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(source, r4); if (zend_is_true(schema)) { - PHALCON_ALLOC_ZVAL_MM(r4); - PHALCON_CONCAT_VSV(r4, schema, ".", source); - PHALCON_CPY_WRT(table, r4); + PHALCON_ALLOC_ZVAL_MM(r5); + PHALCON_CONCAT_VSV(r5, schema, ".", source); + PHALCON_CPY_WRT(table, r5); } else { PHALCON_CPY_WRT(table, source); } eval_int = phalcon_array_isset_string(params, SL("column")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r5); - phalcon_array_fetch_string(&r5, params, SL("column"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(group_column, r5); + PHALCON_ALLOC_ZVAL_MM(r6); + phalcon_array_fetch_string(&r6, params, SL("column"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(group_column, r6); } else { PHALCON_INIT_VAR(group_column); ZVAL_STRING(group_column, "*", 1); @@ -1383,35 +1364,35 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ eval_int = phalcon_array_isset_string(params, SL("distinct")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r6); PHALCON_ALLOC_ZVAL_MM(r7); - phalcon_array_fetch_string(&r7, params, SL("distinct"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVSV(r6, "SELECT ", function, "(DISTINCT ", r7); - PHALCON_CPY_WRT(select, r6); - PHALCON_ALLOC_ZVAL_MM(r8); - PHALCON_CONCAT_SVSVS(r8, ") AS ", alias, " FROM ", table, " "); - phalcon_concat_self(&select, r8 TSRMLS_CC); + phalcon_array_fetch_string(&r8, params, SL("distinct"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVSV(r7, "SELECT ", function, "(DISTINCT ", r8); + PHALCON_CPY_WRT(select, r7); + + PHALCON_ALLOC_ZVAL_MM(r9); + PHALCON_CONCAT_SVSVS(r9, ") AS ", alias, " FROM ", table, " "); + phalcon_concat_self(&select, r9 TSRMLS_CC); } else { eval_int = phalcon_array_isset_string(params, SL("group")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_ALLOC_ZVAL_MM(r10); - phalcon_array_fetch_string(&r10, params, SL("group"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVSVSV(r9, "SELECT ", r10, ", ", function, "(", group_column); - PHALCON_CPY_WRT(select, r9); - PHALCON_ALLOC_ZVAL_MM(r11); - PHALCON_CONCAT_SVSVS(r11, ") AS ", alias, " FROM ", table, " "); - phalcon_concat_self(&select, r11 TSRMLS_CC); - } else { - PHALCON_ALLOC_ZVAL_MM(r12); - PHALCON_CONCAT_SVSVS(r12, "SELECT ", function, "(", group_column, ") AS "); - PHALCON_CPY_WRT(select, r12); + phalcon_array_fetch_string(&r11, params, SL("group"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVSVSV(r10, "SELECT ", r11, ", ", function, "(", group_column); + PHALCON_CPY_WRT(select, r10); + PHALCON_ALLOC_ZVAL_MM(r12); + PHALCON_CONCAT_SVSVS(r12, ") AS ", alias, " FROM ", table, " "); + phalcon_concat_self(&select, r12 TSRMLS_CC); + } else { PHALCON_ALLOC_ZVAL_MM(r13); - PHALCON_CONCAT_VSVS(r13, alias, " FROM ", table, " "); - phalcon_concat_self(&select, r13 TSRMLS_CC); + PHALCON_CONCAT_SVSVS(r13, "SELECT ", function, "(", group_column, ") AS "); + PHALCON_CPY_WRT(select, r13); + + PHALCON_ALLOC_ZVAL_MM(r14); + PHALCON_CONCAT_VSVS(r14, alias, " FROM ", table, " "); + phalcon_concat_self(&select, r14 TSRMLS_CC); } } @@ -1419,67 +1400,67 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ ZVAL_NULL(conditions); eval_int = phalcon_array_isset_string(params, SL("conditions")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r14); - phalcon_array_fetch_string(&r14, params, SL("conditions"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(conditions, r14); + PHALCON_ALLOC_ZVAL_MM(r15); + phalcon_array_fetch_string(&r15, params, SL("conditions"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(conditions, r15); } else { eval_int = phalcon_array_isset_long(params, 0); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r15); - phalcon_array_fetch_long(&r15, params, 0, PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(conditions, r15); + PHALCON_ALLOC_ZVAL_MM(r16); + phalcon_array_fetch_long(&r16, params, 0, PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(conditions, r16); } } if (zend_is_true(conditions)) { - PHALCON_ALLOC_ZVAL_MM(r16); - PHALCON_CONCAT_SV(r16, " WHERE ", conditions); - phalcon_concat_self(&select, r16 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r17); + PHALCON_CONCAT_SV(r17, " WHERE ", conditions); + phalcon_concat_self(&select, r17 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("group")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r17); PHALCON_ALLOC_ZVAL_MM(r18); - phalcon_array_fetch_string(&r18, params, SL("group"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r17, " GROUP BY ", r18, " "); - phalcon_concat_self(&select, r17 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r19); + phalcon_array_fetch_string(&r19, params, SL("group"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r18, " GROUP BY ", r19, " "); + phalcon_concat_self(&select, r18 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("having")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r19); PHALCON_ALLOC_ZVAL_MM(r20); - phalcon_array_fetch_string(&r20, params, SL("having"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r19, " HAVING ", r20, " "); - phalcon_concat_self(&select, r19 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r21); + phalcon_array_fetch_string(&r21, params, SL("having"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r20, " HAVING ", r21, " "); + phalcon_concat_self(&select, r20 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("order")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r21); PHALCON_ALLOC_ZVAL_MM(r22); - phalcon_array_fetch_string(&r22, params, SL("order"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r21, " ORDER BY ", r22, " "); - phalcon_concat_self(&select, r21 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r23); + phalcon_array_fetch_string(&r23, params, SL("order"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r22, " ORDER BY ", r23, " "); + phalcon_concat_self(&select, r22 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("limit")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r23); PHALCON_ALLOC_ZVAL_MM(r24); - phalcon_array_fetch_string(&r24, params, SL("limit"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_2(r23, connection, "_limit", select, r24, PHALCON_NO_CHECK); - PHALCON_CPY_WRT(select, r23); + PHALCON_ALLOC_ZVAL_MM(r25); + phalcon_array_fetch_string(&r25, params, SL("limit"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CALL_METHOD_PARAMS_2(r24, connection, "_limit", select, r25, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(select, r24); } - PHALCON_ALLOC_ZVAL_MM(r25); + PHALCON_ALLOC_ZVAL_MM(r26); p0[0] = connection; p0[1] = params; p0[2] = select; p0[3] = alias; - PHALCON_CALL_SELF_PARAMS(r25, this_ptr, "_getgroupresult", 4, p0); - RETURN_DZVAL(r25); + PHALCON_CALL_SELF_PARAMS(r26, this_ptr, "_getgroupresult", 4, p0); + RETURN_DZVAL(r26); } /** @@ -2063,8 +2044,8 @@ PHP_METHOD(Phalcon_Model_Base, _checkForeignKeys){ int eval_int; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_ALLOC_ZVAL_MM(r0); @@ -2281,8 +2262,8 @@ PHP_METHOD(Phalcon_Model_Base, _checkForeignKeysReverse){ int eval_int; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_ALLOC_ZVAL_MM(r0); @@ -3361,8 +3342,8 @@ PHP_METHOD(Phalcon_Model_Base, writeAttribute){ PHP_METHOD(Phalcon_Model_Base, hasOne){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *options = NULL, *manager = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -3372,17 +3353,16 @@ PHP_METHOD(Phalcon_Model_Base, hasOne){ RETURN_NULL(); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addhasone", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addhasone", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -3404,9 +3384,9 @@ PHP_METHOD(Phalcon_Model_Base, hasOne){ PHP_METHOD(Phalcon_Model_Base, belongsTo){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; + zval *options = NULL, *manager = NULL; zval *a0 = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -3422,17 +3402,16 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ PHALCON_CPY_WRT(options, a0); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addbelongsto", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addbelongsto", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -3443,7 +3422,7 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ /** * Setup a relation 1-n between two models - * +* * * * @param mixed $fields @@ -3454,9 +3433,9 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ PHP_METHOD(Phalcon_Model_Base, hasMany){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; + zval *options = NULL, *manager = NULL; zval *a0 = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -3472,17 +3451,16 @@ PHP_METHOD(Phalcon_Model_Base, hasMany){ PHALCON_CPY_WRT(options, a0); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addhasmany", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addhasmany", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -3530,8 +3508,9 @@ PHP_METHOD(Phalcon_Model_Base, __call){ PHALCON_ALLOC_ZVAL_MM(r0); phalcon_get_class(r0, this_ptr TSRMLS_CC); PHALCON_CPY_WRT(model_name, r0); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_INIT_VAR(c0); diff --git a/dev/model/manager.c b/dev/model/manager.c index 92fed03b324..e35dff18128 100755 --- a/dev/model/manager.c +++ b/dev/model/manager.c @@ -49,13 +49,13 @@ /** * Constructor for Phalcon_Model_Manager - * - * @param Phalcon_Config|stdClass $options +* +* @param Phalcon_Config|stdClass $options */ PHP_METHOD(Phalcon_Model_Manager, __construct){ zval *options = NULL, *model_options = NULL; - zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL; + zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL, *a6 = NULL; zval *t0 = NULL; zval *i0 = NULL; @@ -79,6 +79,11 @@ PHP_METHOD(Phalcon_Model_Manager, __construct){ PHALCON_INIT_VAR(a4); array_init(a4); + zend_update_property(phalcon_model_manager_ce, this_ptr, SL("_sourceNames"), a4 TSRMLS_CC); + + PHALCON_INIT_VAR(a5); + array_init(a5); + zend_update_property(phalcon_model_manager_ce, this_ptr, SL("_initialized"), a5 TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &options) == FAILURE) { PHALCON_MM_RESTORE(); @@ -109,11 +114,11 @@ PHP_METHOD(Phalcon_Model_Manager, __construct){ phalcon_update_property_zval(this_ptr, SL("_options"), model_options TSRMLS_CC); - PHALCON_INIT_VAR(a5); - array_init(a5); - phalcon_array_append(&a5, this_ptr, PHALCON_SEPARATE_PLZ TSRMLS_CC); - add_next_index_stringl(a5, SL("autoload"), 1); - PHALCON_CALL_FUNC_PARAMS_1_NORETURN("spl_autoload_register", a5); + PHALCON_INIT_VAR(a6); + array_init(a6); + phalcon_array_append(&a6, this_ptr, PHALCON_SEPARATE_PLZ TSRMLS_CC); + add_next_index_stringl(a6, SL("autoload"), 1); + PHALCON_CALL_FUNC_PARAMS_1_NORETURN("spl_autoload_register", a6); PHALCON_MM_RESTORE(); } @@ -536,6 +541,49 @@ PHP_METHOD(Phalcon_Model_Manager, getModel){ RETURN_CHECK_CTOR(r0); } +/** + * Initializes a model in the model manager + * + * @param Phalcon_Model_Manager $model + */ +PHP_METHOD(Phalcon_Model_Manager, initialize){ + + zval *model = NULL, *class_name = NULL; + zval *r0 = NULL; + zval *t0 = NULL, *t1 = NULL, *t2 = NULL; + int eval_int; + + PHALCON_MM_GROW(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &model) == FAILURE) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + PHALCON_ALLOC_ZVAL_MM(r0); + phalcon_get_class(r0, model TSRMLS_CC); + PHALCON_CPY_WRT(class_name, r0); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); + eval_int = phalcon_array_isset(t0, class_name); + if (!eval_int) { + if (phalcon_method_exists_ex(model, SL("initialize") TSRMLS_CC) == SUCCESS) { + PHALCON_CALL_METHOD_NORETURN(model, "initialize", PHALCON_NO_CHECK); + } + + PHALCON_INIT_VAR(t1); + ZVAL_BOOL(t1, 1); + + PHALCON_ALLOC_ZVAL_MM(t2); + phalcon_read_property(&t2, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); + phalcon_array_update(&t2, class_name, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_initialized"), t2 TSRMLS_CC); + } + + PHALCON_MM_RESTORE(); +} + /** * Gets the possible source model name from its class name * @@ -544,9 +592,10 @@ PHP_METHOD(Phalcon_Model_Manager, getModel){ */ PHP_METHOD(Phalcon_Model_Manager, getSource){ - zval *model_name = NULL; - zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL; - zval *r0 = NULL; + zval *model_name = NULL, *source_names = NULL, *source_name = NULL; + zval *t0 = NULL, *t1 = NULL; + zval *r0 = NULL, *r1 = NULL; + int eval_int; PHALCON_MM_GROW(); @@ -555,28 +604,27 @@ PHP_METHOD(Phalcon_Model_Manager, getSource){ RETURN_NULL(); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Manager"), SL("_sourceNames") TSRMLS_CC); - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_array_fetch(&t1, t0, model_name, PHALCON_SILENT TSRMLS_CC); - if (!zend_is_true(t1)) { + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_sourceNames"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(source_names, t0); + eval_int = phalcon_array_isset(source_names, model_name); + if (!eval_int) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_1(r0, "phalcon_text", "uncamelize", model_name); - t2 = zend_read_static_property(phalcon_model_manager_ce, SL("_sourceNames"), PHALCON_FETCH_CLASS_SILENT); - if (Z_TYPE_P(t2) != IS_ARRAY) { - convert_to_array(t2); - } - phalcon_array_update(&t2, model_name, &r0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); - phalcon_update_static_property(SL("phalcon_model_manager_ce"), SL("_sourceNames"), t2 TSRMLS_CC); + PHALCON_CPY_WRT(source_name, r0); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_sourceNames"), PHALCON_NOISY TSRMLS_CC); + phalcon_array_update(&t1, model_name, &source_name, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_sourceNames"), t1 TSRMLS_CC); + + RETURN_CHECK_CTOR(source_name); } - PHALCON_OBSERVE_VAR(t3); - phalcon_read_static_property(&t3, SL("Phalcon_Model_Manager"), SL("_sourceNames") TSRMLS_CC); - PHALCON_ALLOC_ZVAL_MM(t4); - phalcon_array_fetch(&t4, t3, model_name, PHALCON_NOISY TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r1); + phalcon_array_fetch(&r1, source_names, model_name, PHALCON_NOISY TSRMLS_CC); - RETURN_CHECK_CTOR(t4); + RETURN_CHECK_CTOR(r1); } /** @@ -586,13 +634,15 @@ PHP_METHOD(Phalcon_Model_Manager, getSource){ */ PHP_METHOD(Phalcon_Model_Manager, getConnection){ - zval *t0 = NULL, *t1 = NULL; + zval *connection = NULL; + zval *t0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(connection, t0); + if (!zend_is_true(connection)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon_transaction_manager", "isautomatic"); if (zend_is_true(r0)) { @@ -611,14 +661,13 @@ PHP_METHOD(Phalcon_Model_Manager, getConnection){ PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CALL_STATIC(r4, "phalcon_db_pool", "getconnection"); - phalcon_update_property_zval(this_ptr, SL("_connection"), r4 TSRMLS_CC); + PHALCON_CPY_WRT(connection, r4); + phalcon_update_property_zval(this_ptr, SL("_connection"), connection TSRMLS_CC); } } - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + RETURN_CHECK_CTOR(connection); } /** diff --git a/dev/model/message.c b/dev/model/message.c index 2b05b26c4c9..a78eec3e145 100755 --- a/dev/model/message.c +++ b/dev/model/message.c @@ -45,12 +45,12 @@ */ /** - * Phalcon_Model_Message message - * - * @param string $message - * @param string $field - * @param string $type - */ +* Phalcon_Model_Message message +* +* @param string $message +* @param string $field +* @param string $type +*/ PHP_METHOD(Phalcon_Model_Message, __construct){ zval *message = NULL, *field = NULL, *type = NULL; @@ -80,10 +80,10 @@ PHP_METHOD(Phalcon_Model_Message, __construct){ } /** - * Sets message type - * - * @param string $type - */ +* Sets message type +* +* @param string $type +*/ PHP_METHOD(Phalcon_Model_Message, setType){ zval *type = NULL; @@ -101,10 +101,10 @@ PHP_METHOD(Phalcon_Model_Message, setType){ } /** - * Returns message type - * - * @return string - */ +* Returns message type +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getType){ zval *t0 = NULL; @@ -117,10 +117,10 @@ PHP_METHOD(Phalcon_Model_Message, getType){ } /** - * Sets verbose message - * - * @param string $message - */ +* Sets verbose message +* +* @param string $message +*/ PHP_METHOD(Phalcon_Model_Message, setMessage){ zval *message = NULL; @@ -138,10 +138,10 @@ PHP_METHOD(Phalcon_Model_Message, setMessage){ } /** - * Returns verbose message - * - * @return string - */ +* Returns verbose message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getMessage){ zval *t0 = NULL; @@ -154,10 +154,10 @@ PHP_METHOD(Phalcon_Model_Message, getMessage){ } /** - * Sets field name related to message - * - * @param string $field - */ +* Sets field name related to message +* +* @param string $field +*/ PHP_METHOD(Phalcon_Model_Message, setField){ zval *field = NULL; @@ -175,10 +175,10 @@ PHP_METHOD(Phalcon_Model_Message, setField){ } /** - * Returns field name related to message - * - * @return string - */ +* Returns field name related to message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getField){ zval *t0 = NULL; @@ -191,10 +191,10 @@ PHP_METHOD(Phalcon_Model_Message, getField){ } /** - * Magic __toString method returns verbose message - * - * @return string - */ +* Magic __toString method returns verbose message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, __toString){ zval *t0 = NULL; @@ -207,11 +207,11 @@ PHP_METHOD(Phalcon_Model_Message, __toString){ } /** - * Magic __set_state helps to recover messsages from serialization - * - * @param array $message - * @return Phalcon_Model_Message - */ +* Magic __set_state helps to recover messsages from serialization +* +* @param array $message +* @return Phalcon_Model_Message +*/ PHP_METHOD(Phalcon_Model_Message, __set_state){ zval *message = NULL; diff --git a/dev/model/metadata.c b/dev/model/metadata.c index 9e41ec258cd..d32c2128174 100755 --- a/dev/model/metadata.c +++ b/dev/model/metadata.c @@ -325,7 +325,7 @@ PHP_METHOD(Phalcon_Model_MetaData, _initializeMetaData){ /** * Returns table attributes names (fields) * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getAttributes){ @@ -411,7 +411,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getPrimaryKeyAttributes){ /** * Returns an arrau of fields which are not part of the primary key * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getNonPrimaryKeyAttributes){ @@ -454,7 +454,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getNonPrimaryKeyAttributes){ /** * Returns an array of not null attributes * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getNotNullAttributes){ @@ -497,7 +497,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getNotNullAttributes){ /** * Returns attributes and their data types * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getDataTypes){ @@ -540,7 +540,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getDataTypes){ /** * Returns attributes which types are numerical * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getDataTypesNumeric){ diff --git a/dev/model/resultset.c b/dev/model/resultset.c index 9a9ba925c40..25da8b0d4e3 100755 --- a/dev/model/resultset.c +++ b/dev/model/resultset.c @@ -52,20 +52,27 @@ * * @param Phalcon_Model_Base $model * @param Phalcon_Model_Result $result + * @param Phalcon_Model_Cache $cache */ PHP_METHOD(Phalcon_Model_Resultset, __construct){ - zval *model = NULL, *result = NULL; + zval *model = NULL, *result = NULL, *cache = NULL; PHALCON_MM_GROW(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model, &result) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &model, &result, &cache) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + if (!cache) { + PHALCON_INIT_VAR(cache); + ZVAL_NULL(cache); + } + phalcon_update_property_zval(this_ptr, SL("_model"), model TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_result"), result TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_cache"), cache TSRMLS_CC); phalcon_update_property_long(this_ptr, SL("_type"), 1 TSRMLS_CC); PHALCON_MM_RESTORE(); @@ -573,3 +580,33 @@ PHP_METHOD(Phalcon_Model_Resultset, unserialize){ PHALCON_MM_RESTORE(); } +/** + * Returns the associated cache for the resultset + * + * @return Phalcon_Cache + */ +PHP_METHOD(Phalcon_Model_Resultset, getCache){ + + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_cache"), PHALCON_NOISY TSRMLS_CC); + + RETURN_CHECK_CTOR(t0); +} + +/** + * Returns an instance of the model that is used to generate each of the results + */ +PHP_METHOD(Phalcon_Model_Resultset, getSourceModel){ + + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_model"), PHALCON_NOISY TSRMLS_CC); + + RETURN_CHECK_CTOR(t0); +} + diff --git a/dev/model/validator/exclusionin.c b/dev/model/validator/exclusionin.c index 543d6302bae..bd1ba606a0d 100644 --- a/dev/model/validator/exclusionin.c +++ b/dev/model/validator/exclusionin.c @@ -43,7 +43,7 @@ */ /** - * Check that the options are valid +* Check that the options are valid * */ PHP_METHOD(Phalcon_Model_Validator_Exclusionin, checkOptions){ diff --git a/dev/model/validator/inclusionin.c b/dev/model/validator/inclusionin.c index 90661f63859..9a60414a6c2 100644 --- a/dev/model/validator/inclusionin.c +++ b/dev/model/validator/inclusionin.c @@ -44,7 +44,7 @@ */ /** - * Check that the options are valid +* Check that the options are valid * */ PHP_METHOD(Phalcon_Model_Validator_Inclusionin, checkOptions){ diff --git a/dev/paginator.c b/dev/paginator.c index fadf5959122..dc168af7fb4 100644 --- a/dev/paginator.c +++ b/dev/paginator.c @@ -45,12 +45,12 @@ */ /** - * Factories a paginator adapter - * - * @param string $adapterName - * @param array $options - * @return Object - */ +* Factories a paginator adapter +* +* @param string $adapterName +* @param array $options +* @return Object +*/ PHP_METHOD(Phalcon_Paginator, factory){ zval *adapter_name = NULL, *options = NULL, *class_name = NULL, *adapter = NULL; diff --git a/dev/paginator/adapter/array.c b/dev/paginator/adapter/array.c index 2d7231da7bb..40f2b1bc4b9 100644 --- a/dev/paginator/adapter/array.c +++ b/dev/paginator/adapter/array.c @@ -44,10 +44,10 @@ */ /** - * Phalcon_Paginator_Adapter_Array constructor +* Phalcon_Paginator_Adapter_Array constructor * * @param array $config - */ +*/ PHP_METHOD(Phalcon_Paginator_Adapter_Array, __construct){ zval *config = NULL; diff --git a/dev/phalcon.c b/dev/phalcon.c index ddc52983b86..4175a92fe75 100755 --- a/dev/phalcon.c +++ b/dev/phalcon.c @@ -545,7 +545,6 @@ PHP_MINIT_FUNCTION(phalcon){ INIT_CLASS_ENTRY(ce_model_base, "Phalcon_Model_Base", phalcon_model_base_functions); phalcon_model_base_ce = zend_register_internal_class(&ce_model_base TSRMLS_CC); - zend_declare_property_bool(phalcon_model_base_ce, SL("_initialized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_model_base_ce, SL("_uniqueKey"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_model_base_ce, SL("_connection"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_model_base_ce, SL("_schema"), "", ZEND_ACC_PROTECTED TSRMLS_CC); @@ -612,7 +611,8 @@ PHP_MINIT_FUNCTION(phalcon){ zend_declare_property_null(phalcon_model_manager_ce, SL("_hasOne"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_belongsTo"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(phalcon_model_manager_ce, SL("_sourceNames"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); + zend_declare_property_null(phalcon_model_manager_ce, SL("_sourceNames"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(phalcon_model_manager_ce, SL("_initialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_default"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); INIT_CLASS_ENTRY(ce_model_metadata_memory, "Phalcon_Model_MetaData_Memory", phalcon_model_metadata_memory_functions); @@ -632,6 +632,7 @@ PHP_MINIT_FUNCTION(phalcon){ zend_declare_property_null(phalcon_model_resultset_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_result"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(phalcon_model_resultset_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_model_resultset_ce, SL("_pointer"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_count"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_activeRow"), ZEND_ACC_PROTECTED TSRMLS_CC); diff --git a/dev/phalcon.h b/dev/phalcon.h index 846545653a0..cd668c07ed6 100755 --- a/dev/phalcon.h +++ b/dev/phalcon.h @@ -945,6 +945,7 @@ PHP_METHOD(Phalcon_Model_Manager, getModelsDir); PHP_METHOD(Phalcon_Model_Manager, isModel); PHP_METHOD(Phalcon_Model_Manager, load); PHP_METHOD(Phalcon_Model_Manager, getModel); +PHP_METHOD(Phalcon_Model_Manager, initialize); PHP_METHOD(Phalcon_Model_Manager, getSource); PHP_METHOD(Phalcon_Model_Manager, getConnection); PHP_METHOD(Phalcon_Model_Manager, addHasOne); @@ -994,6 +995,8 @@ PHP_METHOD(Phalcon_Model_Resultset, getLast); PHP_METHOD(Phalcon_Model_Resultset, isFresh); PHP_METHOD(Phalcon_Model_Resultset, serialize); PHP_METHOD(Phalcon_Model_Resultset, unserialize); +PHP_METHOD(Phalcon_Model_Resultset, getCache); +PHP_METHOD(Phalcon_Model_Resultset, getSourceModel); PHP_METHOD(Phalcon_Tag, setDispatcher); PHP_METHOD(Phalcon_Tag, _getDispatcher); @@ -1034,6 +1037,7 @@ PHP_METHOD(Phalcon_Response, redirect); PHP_METHOD(Phalcon_Response, setContent); PHP_METHOD(Phalcon_Response, appendContent); PHP_METHOD(Phalcon_Response, getContent); +PHP_METHOD(Phalcon_Response, sendHeaders); PHP_METHOD(Phalcon_Response, send); PHP_METHOD(Phalcon_Response, reset); @@ -2792,6 +2796,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_getmodel, 0, 0, 1) ZEND_ARG_INFO(0, modelName) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_initialize, 0, 0, 1) + ZEND_ARG_INFO(0, model) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_getsource, 0, 0, 1) ZEND_ARG_INFO(0, modelName) ZEND_END_ARG_INFO() @@ -2895,6 +2903,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_resultset___construct, 0, 0, 2) ZEND_ARG_INFO(0, model) ZEND_ARG_INFO(0, result) + ZEND_ARG_INFO(0, cache) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_resultset_seek, 0, 0, 1) @@ -4193,8 +4202,8 @@ PHALCON_INIT_FUNCS(phalcon_model_query_functions){ PHALCON_INIT_FUNCS(phalcon_model_base_functions){ PHP_ME(Phalcon_Model_Base, __construct, arginfo_phalcon_model_base___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_CTOR) - PHP_ME(Phalcon_Model_Base, setManager, arginfo_phalcon_model_base_setmanager, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Model_Base, getManager, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Model_Base, setManager, arginfo_phalcon_model_base_setmanager, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Base, getManager, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Base, _connect, NULL, ZEND_ACC_PROTECTED) PHP_ME(Phalcon_Model_Base, getAttributes, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Base, getPrimaryKeyAttributes, NULL, ZEND_ACC_PUBLIC) @@ -4314,6 +4323,7 @@ PHALCON_INIT_FUNCS(phalcon_model_manager_functions){ PHP_ME(Phalcon_Model_Manager, isModel, arginfo_phalcon_model_manager_ismodel, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, load, arginfo_phalcon_model_manager_load, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getModel, arginfo_phalcon_model_manager_getmodel, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Manager, initialize, arginfo_phalcon_model_manager_initialize, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getSource, arginfo_phalcon_model_manager_getsource, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getConnection, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, addHasOne, arginfo_phalcon_model_manager_addhasone, ZEND_ACC_PUBLIC) @@ -4375,6 +4385,8 @@ PHALCON_INIT_FUNCS(phalcon_model_resultset_functions){ PHP_ME(Phalcon_Model_Resultset, isFresh, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Resultset, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Resultset, unserialize, arginfo_phalcon_model_resultset_unserialize, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Resultset, getCache, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Resultset, getSourceModel, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -4421,6 +4433,7 @@ PHALCON_INIT_FUNCS(phalcon_response_functions){ PHP_ME(Phalcon_Response, setContent, arginfo_phalcon_response_setcontent, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, appendContent, arginfo_phalcon_response_appendcontent, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, getContent, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Response, sendHeaders, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, send, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, reset, NULL, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_FE_END diff --git a/dev/request.c b/dev/request.c index e9b72a632b9..aa14b2a74e1 100755 --- a/dev/request.c +++ b/dev/request.c @@ -57,26 +57,28 @@ */ PHP_METHOD(Phalcon_Request, getInstance){ - zval *t0 = NULL, *t1 = NULL; + zval *instance = NULL; + zval *t0 = NULL; zval *i0 = NULL; PHALCON_MM_GROW(); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Request"), SL("_instance") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(instance, t0); + if (!zend_is_true(instance)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_request_ce); - phalcon_update_static_property(SL("Phalcon_Request"), SL("_instance"), i0 TSRMLS_CC); + PHALCON_CPY_WRT(instance, i0); + phalcon_update_static_property(SL("Phalcon_Request"), SL("_instance"), instance TSRMLS_CC); } - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Request"), SL("_instance") TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + + RETURN_CHECK_CTOR(instance); } /** * Overwrites Phalcon_Filter object used to sanitize input data - * +* * * * @param Phalcon_Filter $filter @@ -176,7 +178,7 @@ PHP_METHOD(Phalcon_Request, getPost){ /** * Gets variable from $_GET superglobal applying filters if needed - * +* * * * @param string $name diff --git a/dev/response.c b/dev/response.c index b97e345f8cb..793610afaab 100755 --- a/dev/response.c +++ b/dev/response.c @@ -50,21 +50,23 @@ */ PHP_METHOD(Phalcon_Response, getInstance){ - zval *t0 = NULL, *t1 = NULL; + zval *instance = NULL; + zval *t0 = NULL; zval *i0 = NULL; PHALCON_MM_GROW(); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Response"), SL("_instance") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(instance, t0); + if (!zend_is_true(instance)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_response_ce); - phalcon_update_static_property(SL("Phalcon_Response"), SL("_instance"), i0 TSRMLS_CC); + PHALCON_CPY_WRT(instance, i0); + phalcon_update_static_property(SL("Phalcon_Response"), SL("_instance"), instance TSRMLS_CC); } - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Response"), SL("_instance") TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + + RETURN_CHECK_CTOR(instance); } /** @@ -166,7 +168,7 @@ PHP_METHOD(Phalcon_Response, setHeader){ * Send a raw header to the response * * - * +* * @param string $header * @return Phalcon_Response */ @@ -334,7 +336,7 @@ PHP_METHOD(Phalcon_Response, redirect){ /** * Sets HTTP response body - * +* * * * @param string $content @@ -399,6 +401,26 @@ PHP_METHOD(Phalcon_Response, getContent){ RETURN_CHECK_CTOR(t0); } +/** + * Sends headers to the client + * + */ +PHP_METHOD(Phalcon_Response, sendHeaders){ + + zval *headers = NULL; + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(headers, t0); + if (zend_is_true(headers)) { + PHALCON_CALL_METHOD_NORETURN(headers, "send", PHALCON_NO_CHECK); + } + + PHALCON_MM_RESTORE(); +} + /** * Prints out HTTP response to the client * diff --git a/dev/response/headers.c b/dev/response/headers.c index e0bd0cf97c7..799b8e60c71 100755 --- a/dev/response/headers.c +++ b/dev/response/headers.c @@ -36,6 +36,14 @@ #include "kernel/array.h" #include "kernel/fcall.h" #include "kernel/concat.h" +/** + * Phalcon_Response_Headers + * + * This class is a bag to manage the response headers + * + * + */ + PHP_METHOD(Phalcon_Response_Headers, __construct){ zval *a0 = NULL; @@ -49,6 +57,12 @@ PHP_METHOD(Phalcon_Response_Headers, __construct){ PHALCON_MM_RESTORE(); } +/** + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value + */ PHP_METHOD(Phalcon_Response_Headers, set){ zval *name = NULL, *value = NULL; @@ -69,6 +83,12 @@ PHP_METHOD(Phalcon_Response_Headers, set){ PHALCON_MM_RESTORE(); } +/** + * Sets a header value from the internal bag + * + * @param string $name + * @return string + */ PHP_METHOD(Phalcon_Response_Headers, get){ zval *name = NULL, *headers = NULL; @@ -98,6 +118,11 @@ PHP_METHOD(Phalcon_Response_Headers, get){ RETURN_FALSE; } +/** + * Sets a raw header to be sent at the end of the request + * + * @param string $header + */ PHP_METHOD(Phalcon_Response_Headers, setRaw){ zval *header = NULL; @@ -120,11 +145,14 @@ PHP_METHOD(Phalcon_Response_Headers, setRaw){ PHALCON_MM_RESTORE(); } +/** + * Sends the headers to the client + */ PHP_METHOD(Phalcon_Response_Headers, send){ zval *t = NULL, *value = NULL, *header = NULL; + zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; - zval *r0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; @@ -134,38 +162,44 @@ PHP_METHOD(Phalcon_Response_Headers, send){ int hash_type; PHALCON_MM_GROW(); - PHALCON_INIT_VAR(t); - ZVAL_BOOL(t, 1); - - PHALCON_ALLOC_ZVAL_MM(t0); - phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); - if (phalcon_valid_foreach(t0 TSRMLS_CC)) { - ah0 = Z_ARRVAL_P(t0); - zend_hash_internal_pointer_reset_ex(ah0, &hp0); - fes_ae51_0: - if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ - goto fee_ae51_0; - } else { - PHALCON_INIT_VAR(header); - PHALCON_GET_FOREACH_KEY(header, ah0, hp0); - } - PHALCON_INIT_VAR(value); - ZVAL_ZVAL(value, *hd, 1, 0); - if (zend_is_true(value)) { - PHALCON_INIT_VAR(r0); - PHALCON_CONCAT_VSV(r0, header, ": ", value); - PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", r0, t); + PHALCON_ALLOC_ZVAL_MM(r0); + PHALCON_CALL_FUNC(r0, "headers_sent"); + if (!zend_is_true(r0)) { + PHALCON_INIT_VAR(t); + ZVAL_BOOL(t, 1); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); + if (phalcon_valid_foreach(t0 TSRMLS_CC)) { + ah0 = Z_ARRVAL_P(t0); + zend_hash_internal_pointer_reset_ex(ah0, &hp0); + fes_ae51_0: + if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ + goto fee_ae51_0; + } else { + PHALCON_INIT_VAR(header); + PHALCON_GET_FOREACH_KEY(header, ah0, hp0); + } + PHALCON_INIT_VAR(value); + ZVAL_ZVAL(value, *hd, 1, 0); + if (zend_is_true(value)) { + PHALCON_INIT_VAR(r1); + PHALCON_CONCAT_VSV(r1, header, ": ", value); + PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", r1, t); + } else { + PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", header, t); + } + zend_hash_move_forward_ex(ah0, &hp0); + goto fes_ae51_0; + fee_ae51_0: + if(0){} } else { - PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", header, t); + return; } - zend_hash_move_forward_ex(ah0, &hp0); - goto fes_ae51_0; - fee_ae51_0: - if(0){} - } else { - return; + PHALCON_MM_RESTORE(); + RETURN_TRUE; } - PHALCON_MM_RESTORE(); + RETURN_FALSE; } diff --git a/dev/transaction.c b/dev/transaction.c index 9f31f8501af..a68f3ad59cf 100755 --- a/dev/transaction.c +++ b/dev/transaction.c @@ -487,10 +487,10 @@ PHP_METHOD(Phalcon_Transaction, getMessages){ } /** - * Checks whether internal connection is under an active transaction - * - * @return boolean - */ +* Checks whether internal connection is under an active transaction +* +* @return boolean +*/ PHP_METHOD(Phalcon_Transaction, isValid){ zval *r0 = NULL; diff --git a/dev/translate.c b/dev/translate.c index bb71bdc96aa..fd66a2cc0f8 100644 --- a/dev/translate.c +++ b/dev/translate.c @@ -144,11 +144,11 @@ PHP_METHOD(Phalcon_Translate, offsetSet){ } /** - * Check whether a translation key exists - * - * @param string $translateKey - * @return boolean - */ +* Check whether a translation key exists +* +* @param string $translateKey +* @return boolean +*/ PHP_METHOD(Phalcon_Translate, offsetExists){ zval *translate_key = NULL; @@ -170,10 +170,10 @@ PHP_METHOD(Phalcon_Translate, offsetExists){ } /** - * Elimina un indice del diccionario - * - * @param string $offset - */ +* Elimina un indice del diccionario +* +* @param string $offset +*/ PHP_METHOD(Phalcon_Translate, offsetUnset){ zval *offset = NULL; diff --git a/release/phalcon.c b/release/phalcon.c index b251d64bec7..dfc20ed5384 100644 --- a/release/phalcon.c +++ b/release/phalcon.c @@ -2273,7 +2273,7 @@ int phalcon_require(zval *require_path TSRMLS_DC){ zend_file_handle file_handle; zval *result = NULL; int status = SUCCESS; - int dummy; + int dummy = 0; zval **original_return_value = EG(return_value_ptr_ptr); zend_op **original_opline_ptr = EG(opline_ptr); @@ -6580,10 +6580,10 @@ PHP_METHOD(Phalcon_Db, delete){ } /** - * Starts a transaction in the connection - * - * @return boolean - */ +* Starts a transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, begin){ zval *r0 = NULL; @@ -6602,10 +6602,10 @@ PHP_METHOD(Phalcon_Db, begin){ } /** - * Rollbacks the active transaction in the connection - * - * @return boolean - */ +* Rollbacks the active transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, rollback){ zval *t0 = NULL; @@ -6634,10 +6634,10 @@ PHP_METHOD(Phalcon_Db, rollback){ } /** - * Commits the active transaction in the connection - * - * @return boolean - */ +* Commits the active transaction in the connection +* +* @return boolean +*/ PHP_METHOD(Phalcon_Db, commit){ zval *t0 = NULL; @@ -6819,7 +6819,7 @@ PHP_METHOD(Phalcon_Db, getUsername){ /** * Returns the username which has connected to the database - * +* * @return string */ PHP_METHOD(Phalcon_Db, getHostName){ @@ -6853,10 +6853,10 @@ PHP_METHOD(Phalcon_Db, getHostName){ */ PHP_METHOD(Phalcon_Db, _beforeQuery){ - zval *sql_statement = NULL; - zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL; + zval *sql_statement = NULL, *logger = NULL, *profiler = NULL; + zval *t0 = NULL, *t1 = NULL; zval *r0 = NULL, *r1 = NULL; - zval *c0 = NULL; + zval *c0 = NULL, *c1 = NULL; PHALCON_MM_GROW(); @@ -6867,26 +6867,24 @@ PHP_METHOD(Phalcon_Db, _beforeQuery){ PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_logger"), PHALCON_NOISY TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_logger"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(logger, t0); + if (zend_is_true(logger)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 1); PHALCON_CALL_METHOD_PARAMS_1(r1, this_ptr, "getconnectionid", c0, PHALCON_NO_CHECK); PHALCON_CONCAT_SVSV(r0, "[", r1, "] ", sql_statement); - PHALCON_ALLOC_ZVAL_MM(t2); - phalcon_get_class_constant(t2, phalcon_logger_ce, SL("DEBUG") TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(t1, "log", r0, t2, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(c1); + ZVAL_LONG(c1, 7); + PHALCON_CALL_METHOD_PARAMS_2_NORETURN(logger, "log", r0, c1, PHALCON_NO_CHECK); } - PHALCON_ALLOC_ZVAL_MM(t3); - phalcon_read_property(&t3, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); - if (zend_is_true(t3)) { - PHALCON_ALLOC_ZVAL_MM(t4); - phalcon_read_property(&t4, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t4, "startprofile", sql_statement, PHALCON_NO_CHECK); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_profiler"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(profiler, t1); + if (zend_is_true(profiler)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(profiler, "startprofile", sql_statement, PHALCON_NO_CHECK); } PHALCON_MM_RESTORE(); @@ -12394,10 +12392,10 @@ PHP_METHOD(Phalcon_View_Engine_Mustache, __call){ */ /** - * Phalcon_Paginator_Adapter_Array constructor +* Phalcon_Paginator_Adapter_Array constructor * * @param array $config - */ +*/ PHP_METHOD(Phalcon_Paginator_Adapter_Array, __construct){ zval *config = NULL; @@ -13530,12 +13528,12 @@ PHP_METHOD(Phalcon_Request_File, getTempName){ */ /** - * Factories a paginator adapter - * - * @param string $adapterName - * @param array $options - * @return Object - */ +* Factories a paginator adapter +* +* @param string $adapterName +* @param array $options +* @return Object +*/ PHP_METHOD(Phalcon_Paginator, factory){ zval *adapter_name = NULL, *options = NULL, *class_name = NULL, *adapter = NULL; @@ -13708,6 +13706,14 @@ PHP_METHOD(Phalcon_Utils, getLocalPath){ * */ +/** + * Phalcon_Response_Headers + * + * This class is a bag to manage the response headers + * + * + */ + PHP_METHOD(Phalcon_Response_Headers, __construct){ zval *a0 = NULL; @@ -13721,6 +13727,12 @@ PHP_METHOD(Phalcon_Response_Headers, __construct){ PHALCON_MM_RESTORE(); } +/** + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value + */ PHP_METHOD(Phalcon_Response_Headers, set){ zval *name = NULL, *value = NULL; @@ -13741,6 +13753,12 @@ PHP_METHOD(Phalcon_Response_Headers, set){ PHALCON_MM_RESTORE(); } +/** + * Sets a header value from the internal bag + * + * @param string $name + * @return string + */ PHP_METHOD(Phalcon_Response_Headers, get){ zval *name = NULL, *headers = NULL; @@ -13770,6 +13788,11 @@ PHP_METHOD(Phalcon_Response_Headers, get){ RETURN_FALSE; } +/** + * Sets a raw header to be sent at the end of the request + * + * @param string $header + */ PHP_METHOD(Phalcon_Response_Headers, setRaw){ zval *header = NULL; @@ -13792,11 +13815,14 @@ PHP_METHOD(Phalcon_Response_Headers, setRaw){ PHALCON_MM_RESTORE(); } +/** + * Sends the headers to the client + */ PHP_METHOD(Phalcon_Response_Headers, send){ zval *t = NULL, *value = NULL, *header = NULL; + zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; - zval *r0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; @@ -13806,39 +13832,45 @@ PHP_METHOD(Phalcon_Response_Headers, send){ int hash_type; PHALCON_MM_GROW(); - PHALCON_INIT_VAR(t); - ZVAL_BOOL(t, 1); - - PHALCON_ALLOC_ZVAL_MM(t0); - phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); - if (phalcon_valid_foreach(t0 TSRMLS_CC)) { - ah0 = Z_ARRVAL_P(t0); - zend_hash_internal_pointer_reset_ex(ah0, &hp0); - fes_ae51_0: - if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ - goto fee_ae51_0; - } else { - PHALCON_INIT_VAR(header); - PHALCON_GET_FOREACH_KEY(header, ah0, hp0); - } - PHALCON_INIT_VAR(value); - ZVAL_ZVAL(value, *hd, 1, 0); - if (zend_is_true(value)) { - PHALCON_INIT_VAR(r0); - PHALCON_CONCAT_VSV(r0, header, ": ", value); - PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", r0, t); + PHALCON_ALLOC_ZVAL_MM(r0); + PHALCON_CALL_FUNC(r0, "headers_sent"); + if (!zend_is_true(r0)) { + PHALCON_INIT_VAR(t); + ZVAL_BOOL(t, 1); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); + if (phalcon_valid_foreach(t0 TSRMLS_CC)) { + ah0 = Z_ARRVAL_P(t0); + zend_hash_internal_pointer_reset_ex(ah0, &hp0); + fes_ae51_0: + if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ + goto fee_ae51_0; + } else { + PHALCON_INIT_VAR(header); + PHALCON_GET_FOREACH_KEY(header, ah0, hp0); + } + PHALCON_INIT_VAR(value); + ZVAL_ZVAL(value, *hd, 1, 0); + if (zend_is_true(value)) { + PHALCON_INIT_VAR(r1); + PHALCON_CONCAT_VSV(r1, header, ": ", value); + PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", r1, t); + } else { + PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", header, t); + } + zend_hash_move_forward_ex(ah0, &hp0); + goto fes_ae51_0; + fee_ae51_0: + if(0){} } else { - PHALCON_CALL_FUNC_PARAMS_2_NORETURN("header", header, t); + return; } - zend_hash_move_forward_ex(ah0, &hp0); - goto fes_ae51_0; - fee_ae51_0: - if(0){} - } else { - return; + PHALCON_MM_RESTORE(); + RETURN_TRUE; } - PHALCON_MM_RESTORE(); + RETURN_FALSE; } /** @@ -13945,7 +13977,7 @@ PHP_METHOD(Phalcon_Dispatcher, getBasePath){ /** * Sets the default controller name - * +* * @param string $controllerName */ PHP_METHOD(Phalcon_Dispatcher, setDefaultController){ @@ -13966,7 +13998,7 @@ PHP_METHOD(Phalcon_Dispatcher, setDefaultController){ /** * Sets the default action name - * +* * @param string $actionName */ PHP_METHOD(Phalcon_Dispatcher, setDefaultAction){ @@ -14098,9 +14130,9 @@ PHP_METHOD(Phalcon_Dispatcher, getParams){ /** * Set a param by its name or numeric index - * - * @param mixed $param - * @param mixed $value +* +* @param mixed $param +* @param mixed $value */ PHP_METHOD(Phalcon_Dispatcher, setParam){ @@ -14124,8 +14156,8 @@ PHP_METHOD(Phalcon_Dispatcher, setParam){ /** * Gets a param by its name or numeric index - * - * @param mixed $param +* +* @param mixed $param * @return mixed */ PHP_METHOD(Phalcon_Dispatcher, getParam){ @@ -14564,7 +14596,7 @@ PHP_METHOD(Phalcon_Dispatcher, getControllers){ } /** - * Returns last dispatched controller + * Returns the lastest dispatched controller * * @return Phalcon_Controller */ @@ -14580,7 +14612,7 @@ PHP_METHOD(Phalcon_Dispatcher, getLastController){ } /** - * Returns value returned by last dispacthed action + * Returns value returned by the lastest dispatched action * * @return mixed */ @@ -14704,11 +14736,11 @@ PHP_METHOD(Phalcon_Translate, offsetSet){ } /** - * Check whether a translation key exists - * - * @param string $translateKey - * @return boolean - */ +* Check whether a translation key exists +* +* @param string $translateKey +* @return boolean +*/ PHP_METHOD(Phalcon_Translate, offsetExists){ zval *translate_key = NULL; @@ -14730,10 +14762,10 @@ PHP_METHOD(Phalcon_Translate, offsetExists){ } /** - * Elimina un indice del diccionario - * - * @param string $offset - */ +* Elimina un indice del diccionario +* +* @param string $offset +*/ PHP_METHOD(Phalcon_Translate, offsetUnset){ zval *offset = NULL; @@ -14880,7 +14912,7 @@ PHP_METHOD(Phalcon_Db_Pool, setDefaultDescriptor){ * * * @param boolean $newConnection - * @param boolean $renovate +* @param boolean $renovate * @return Phalcon_Db */ PHP_METHOD(Phalcon_Db_Pool, getConnection){ @@ -15103,7 +15135,7 @@ PHP_METHOD(Phalcon_Db_Profiler, stopProfile){ } /** - * Returns the total number of SQL statements processed +* Returns the total number of SQL statements processed * * @return integer */ @@ -22140,7 +22172,7 @@ PHP_METHOD(Phalcon_Model_Validator_Uniqueness, validate){ */ /** - * Check that the options are valid +* Check that the options are valid * */ PHP_METHOD(Phalcon_Model_Validator_Exclusionin, checkOptions){ @@ -22339,7 +22371,7 @@ PHP_METHOD(Phalcon_Model_Validator_Regex, validate){ */ /** - * Check that the options are valid +* Check that the options are valid * */ PHP_METHOD(Phalcon_Model_Validator_Inclusionin, checkOptions){ @@ -22983,9 +23015,9 @@ PHP_METHOD(Phalcon_Model_Query, fromInput){ */ PHP_METHOD(Phalcon_Model_Base, __construct){ - zval *manager = NULL, *class_name = NULL; - zval *t0 = NULL, *t1 = NULL; - zval *r0 = NULL, *r1 = NULL; + zval *manager = NULL; + zval *t0 = NULL; + zval *r0 = NULL; PHALCON_MM_GROW(); @@ -22997,32 +23029,24 @@ PHP_METHOD(Phalcon_Model_Base, __construct){ if (!manager) { PHALCON_INIT_VAR(manager); ZVAL_NULL(manager); + } else { + PHALCON_SEPARATE_PARAM(manager); } if (!zend_is_true(manager)) { - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (!zend_is_true(manager)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), r0 TSRMLS_CC); + PHALCON_CPY_WRT(manager, r0); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); } } else { - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), manager TSRMLS_CC); - } - - PHALCON_ALLOC_ZVAL_MM(r1); - phalcon_get_class(r1, this_ptr TSRMLS_CC); - PHALCON_CPY_WRT(class_name, r1); - - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); - if (!zend_is_true(t1)) { - if (phalcon_method_exists_ex(this_ptr, SL("initialize") TSRMLS_CC) == SUCCESS) { - PHALCON_CALL_METHOD_NORETURN(this_ptr, "initialize", PHALCON_NO_CHECK); - } - phalcon_update_property_bool(this_ptr, SL("_initialized"), 1 TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); } + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(manager, "initialize", this_ptr, PHALCON_NO_CHECK); PHALCON_MM_RESTORE(); } @@ -23043,7 +23067,7 @@ PHP_METHOD(Phalcon_Model_Base, setManager){ RETURN_NULL(); } - phalcon_update_static_property(SL("Phalcon_Model_Base"), SL("_manager"), manager TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); PHALCON_MM_RESTORE(); } @@ -23058,8 +23082,8 @@ PHP_METHOD(Phalcon_Model_Base, getManager){ zval *t0 = NULL; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); RETURN_CHECK_CTOR(t0); } @@ -23078,8 +23102,8 @@ PHP_METHOD(Phalcon_Model_Base, _connect){ phalcon_read_property(&t0, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r0, t1, "getconnection", PHALCON_NO_CHECK); phalcon_update_property_zval(this_ptr, SL("_connection"), r0 TSRMLS_CC); } @@ -23101,8 +23125,8 @@ PHP_METHOD(Phalcon_Model_Base, getAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23121,8 +23145,8 @@ PHP_METHOD(Phalcon_Model_Base, getPrimaryKeyAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getprimarykeyattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23141,8 +23165,8 @@ PHP_METHOD(Phalcon_Model_Base, getNonPrimaryKeyAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getnonprimarykeyattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23161,8 +23185,8 @@ PHP_METHOD(Phalcon_Model_Base, getNotNullAttributes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getnotnullattributes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23181,8 +23205,8 @@ PHP_METHOD(Phalcon_Model_Base, getDataTypesNumeric){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getdatatypesnumeric", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23201,8 +23225,8 @@ PHP_METHOD(Phalcon_Model_Base, getDataTypes){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getdatatypes", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23221,8 +23245,8 @@ PHP_METHOD(Phalcon_Model_Base, getIdentityField){ PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(r1, t0, "getmetadata", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1(r0, r1, "getidentityfield", this_ptr, PHALCON_NO_CHECK); RETURN_DZVAL(r0); @@ -23638,7 +23662,7 @@ PHP_METHOD(Phalcon_Model_Base, _getOrCreateResultset){ PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_model_resultset_ce); - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(i0, "__construct", model, result_data, PHALCON_CHECK); + PHALCON_CALL_METHOD_PARAMS_3_NORETURN(i0, "__construct", model, result_data, cache, PHALCON_CHECK); PHALCON_CPY_WRT(resultset, i0); if (Z_TYPE_P(cache) != IS_NULL) { PHALCON_CALL_METHOD_PARAMS_3_NORETURN(cache, "save", key, resultset, lifetime, PHALCON_NO_CHECK); @@ -23731,8 +23755,8 @@ PHP_METHOD(Phalcon_Model_Base, getSource){ phalcon_read_property(&t0, this_ptr, SL("_source"), PHALCON_NOISY TSRMLS_CC); if (!zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r1); phalcon_get_class(r1, this_ptr TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_1(r0, t1, "getsource", r1, PHALCON_NO_CHECK); @@ -23891,13 +23915,11 @@ PHP_METHOD(Phalcon_Model_Base, dumpResult){ */ PHP_METHOD(Phalcon_Model_Base, find){ - zval *parameters = NULL, *class_name = NULL, *model = NULL, *manager = NULL; + zval *parameters = NULL, *manager = NULL, *class_name = NULL, *model = NULL; zval *connection = NULL, *params = NULL; - zval *i0 = NULL; - zval *r0 = NULL, *r1 = NULL, *r2 = NULL; + zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -23911,26 +23933,24 @@ PHP_METHOD(Phalcon_Model_Base, find){ ZVAL_NULL(parameters); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -23947,7 +23967,7 @@ PHP_METHOD(Phalcon_Model_Base, find){ PHALCON_CPY_WRT(params, parameters); } - PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_ALLOC_ZVAL_MM(r3); p0[0] = manager; p0[1] = model; p0[2] = connection; @@ -23955,8 +23975,8 @@ PHP_METHOD(Phalcon_Model_Base, find){ PHALCON_INIT_VAR(p0[4]); ZVAL_BOOL(p0[4], 0); - PHALCON_CALL_SELF_PARAMS(r2, this_ptr, "_getorcreateresultset", 5, p0); - RETURN_DZVAL(r2); + PHALCON_CALL_SELF_PARAMS(r3, this_ptr, "_getorcreateresultset", 5, p0); + RETURN_DZVAL(r3); } /** @@ -23969,15 +23989,13 @@ PHP_METHOD(Phalcon_Model_Base, find){ */ PHP_METHOD(Phalcon_Model_Base, findFirst){ - zval *parameters = NULL, *class_name = NULL, *model = NULL, *manager = NULL; + zval *parameters = NULL, *manager = NULL, *class_name = NULL, *model = NULL; zval *connection = NULL, *params = NULL; - zval *i0 = NULL; - zval *r0 = NULL, *r1 = NULL, *r2 = NULL; + zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *a0 = NULL, *a1 = NULL; zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; int eval_int; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -23991,26 +24009,24 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ ZVAL_NULL(parameters); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -24034,7 +24050,7 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ phalcon_array_update_string(¶ms, SL("limit"), &t0, PHALCON_SEPARATE_PLZ, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } - PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_ALLOC_ZVAL_MM(r3); p0[0] = manager; p0[1] = model; p0[2] = connection; @@ -24042,8 +24058,8 @@ PHP_METHOD(Phalcon_Model_Base, findFirst){ PHALCON_INIT_VAR(p0[4]); ZVAL_BOOL(p0[4], 1); - PHALCON_CALL_SELF_PARAMS(r2, this_ptr, "_getorcreateresultset", 5, p0); - RETURN_DZVAL(r2); + PHALCON_CALL_SELF_PARAMS(r3, this_ptr, "_getorcreateresultset", 5, p0); + RETURN_DZVAL(r3); } /** @@ -24217,21 +24233,20 @@ PHP_METHOD(Phalcon_Model_Base, _exists){ * @param string $function * @param string $alias * @param array $parameters + * @return Phalcon_Model_Resultset */ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ - zval *function = NULL, *alias = NULL, *parameters = NULL, *class_name = NULL; - zval *model = NULL, *manager = NULL, *connection = NULL, *params = NULL, *schema = NULL; - zval *source = NULL, *table = NULL, *group_column = NULL, *select = NULL, *conditions = NULL; - zval *i0 = NULL; + zval *function = NULL, *alias = NULL, *parameters = NULL, *manager = NULL, *class_name = NULL; + zval *model = NULL, *connection = NULL, *params = NULL, *schema = NULL, *source = NULL; + zval *table = NULL, *group_column = NULL, *select = NULL, *conditions = 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, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL, *r19 = NULL, *r20 = NULL; - zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL; + zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL, *r26 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL }; int eval_int; - zend_class_entry *ce0; PHALCON_MM_GROW(); @@ -24240,26 +24255,24 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ RETURN_NULL(); } - PHALCON_INIT_VAR(class_name); - PHALCON_CALL_FUNC(class_name, "get_called_class"); - ce0 = phalcon_fetch_class(class_name TSRMLS_CC); - - PHALCON_ALLOC_ZVAL_MM(i0); - object_init_ex(i0, ce0); - PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PHALCON_CHECK); - PHALCON_CPY_WRT(model, i0); - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_ZVAL_STATIC(r0, class_name, "getmanager"); + PHALCON_CALL_STATIC(r0, "phalcon_model_manager", "getdefault"); PHALCON_CPY_WRT(manager, r0); if (!zend_is_true(manager)) { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not model manager related to this model"); return; } + PHALCON_INIT_VAR(class_name); + PHALCON_CALL_FUNC(class_name, "get_called_class"); + PHALCON_ALLOC_ZVAL_MM(r1); - PHALCON_CALL_METHOD(r1, manager, "getconnection", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(connection, r1); + PHALCON_CALL_METHOD_PARAMS_1(r1, manager, "getmodel", class_name, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(model, r1); + + PHALCON_ALLOC_ZVAL_MM(r2); + PHALCON_CALL_METHOD(r2, manager, "getconnection", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(connection, r2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(model, "setconnection", connection, PHALCON_NO_CHECK); if (Z_TYPE_P(parameters) != IS_ARRAY) { if (Z_TYPE_P(parameters) != IS_NULL) { @@ -24276,26 +24289,26 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ PHALCON_CPY_WRT(params, parameters); } - PHALCON_ALLOC_ZVAL_MM(r2); - PHALCON_CALL_METHOD(r2, model, "getschema", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(schema, r2); - PHALCON_ALLOC_ZVAL_MM(r3); - PHALCON_CALL_METHOD(r3, model, "getsource", PHALCON_NO_CHECK); - PHALCON_CPY_WRT(source, r3); + PHALCON_CALL_METHOD(r3, model, "getschema", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(schema, r3); + + PHALCON_ALLOC_ZVAL_MM(r4); + PHALCON_CALL_METHOD(r4, model, "getsource", PHALCON_NO_CHECK); + PHALCON_CPY_WRT(source, r4); if (zend_is_true(schema)) { - PHALCON_ALLOC_ZVAL_MM(r4); - PHALCON_CONCAT_VSV(r4, schema, ".", source); - PHALCON_CPY_WRT(table, r4); + PHALCON_ALLOC_ZVAL_MM(r5); + PHALCON_CONCAT_VSV(r5, schema, ".", source); + PHALCON_CPY_WRT(table, r5); } else { PHALCON_CPY_WRT(table, source); } eval_int = phalcon_array_isset_string(params, SL("column")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r5); - phalcon_array_fetch_string(&r5, params, SL("column"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(group_column, r5); + PHALCON_ALLOC_ZVAL_MM(r6); + phalcon_array_fetch_string(&r6, params, SL("column"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(group_column, r6); } else { PHALCON_INIT_VAR(group_column); ZVAL_STRING(group_column, "*", 1); @@ -24303,35 +24316,35 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ eval_int = phalcon_array_isset_string(params, SL("distinct")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r6); PHALCON_ALLOC_ZVAL_MM(r7); - phalcon_array_fetch_string(&r7, params, SL("distinct"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVSV(r6, "SELECT ", function, "(DISTINCT ", r7); - PHALCON_CPY_WRT(select, r6); - PHALCON_ALLOC_ZVAL_MM(r8); - PHALCON_CONCAT_SVSVS(r8, ") AS ", alias, " FROM ", table, " "); - phalcon_concat_self(&select, r8 TSRMLS_CC); + phalcon_array_fetch_string(&r8, params, SL("distinct"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVSV(r7, "SELECT ", function, "(DISTINCT ", r8); + PHALCON_CPY_WRT(select, r7); + + PHALCON_ALLOC_ZVAL_MM(r9); + PHALCON_CONCAT_SVSVS(r9, ") AS ", alias, " FROM ", table, " "); + phalcon_concat_self(&select, r9 TSRMLS_CC); } else { eval_int = phalcon_array_isset_string(params, SL("group")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_ALLOC_ZVAL_MM(r10); - phalcon_array_fetch_string(&r10, params, SL("group"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVSVSV(r9, "SELECT ", r10, ", ", function, "(", group_column); - PHALCON_CPY_WRT(select, r9); - PHALCON_ALLOC_ZVAL_MM(r11); - PHALCON_CONCAT_SVSVS(r11, ") AS ", alias, " FROM ", table, " "); - phalcon_concat_self(&select, r11 TSRMLS_CC); - } else { - PHALCON_ALLOC_ZVAL_MM(r12); - PHALCON_CONCAT_SVSVS(r12, "SELECT ", function, "(", group_column, ") AS "); - PHALCON_CPY_WRT(select, r12); + phalcon_array_fetch_string(&r11, params, SL("group"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVSVSV(r10, "SELECT ", r11, ", ", function, "(", group_column); + PHALCON_CPY_WRT(select, r10); + PHALCON_ALLOC_ZVAL_MM(r12); + PHALCON_CONCAT_SVSVS(r12, ") AS ", alias, " FROM ", table, " "); + phalcon_concat_self(&select, r12 TSRMLS_CC); + } else { PHALCON_ALLOC_ZVAL_MM(r13); - PHALCON_CONCAT_VSVS(r13, alias, " FROM ", table, " "); - phalcon_concat_self(&select, r13 TSRMLS_CC); + PHALCON_CONCAT_SVSVS(r13, "SELECT ", function, "(", group_column, ") AS "); + PHALCON_CPY_WRT(select, r13); + + PHALCON_ALLOC_ZVAL_MM(r14); + PHALCON_CONCAT_VSVS(r14, alias, " FROM ", table, " "); + phalcon_concat_self(&select, r14 TSRMLS_CC); } } @@ -24339,67 +24352,67 @@ PHP_METHOD(Phalcon_Model_Base, _prepareGroupResult){ ZVAL_NULL(conditions); eval_int = phalcon_array_isset_string(params, SL("conditions")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r14); - phalcon_array_fetch_string(&r14, params, SL("conditions"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(conditions, r14); + PHALCON_ALLOC_ZVAL_MM(r15); + phalcon_array_fetch_string(&r15, params, SL("conditions"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(conditions, r15); } else { eval_int = phalcon_array_isset_long(params, 0); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r15); - phalcon_array_fetch_long(&r15, params, 0, PHALCON_NOISY TSRMLS_CC); - PHALCON_CPY_WRT(conditions, r15); + PHALCON_ALLOC_ZVAL_MM(r16); + phalcon_array_fetch_long(&r16, params, 0, PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(conditions, r16); } } if (zend_is_true(conditions)) { - PHALCON_ALLOC_ZVAL_MM(r16); - PHALCON_CONCAT_SV(r16, " WHERE ", conditions); - phalcon_concat_self(&select, r16 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r17); + PHALCON_CONCAT_SV(r17, " WHERE ", conditions); + phalcon_concat_self(&select, r17 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("group")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r17); PHALCON_ALLOC_ZVAL_MM(r18); - phalcon_array_fetch_string(&r18, params, SL("group"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r17, " GROUP BY ", r18, " "); - phalcon_concat_self(&select, r17 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r19); + phalcon_array_fetch_string(&r19, params, SL("group"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r18, " GROUP BY ", r19, " "); + phalcon_concat_self(&select, r18 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("having")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r19); PHALCON_ALLOC_ZVAL_MM(r20); - phalcon_array_fetch_string(&r20, params, SL("having"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r19, " HAVING ", r20, " "); - phalcon_concat_self(&select, r19 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r21); + phalcon_array_fetch_string(&r21, params, SL("having"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r20, " HAVING ", r21, " "); + phalcon_concat_self(&select, r20 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("order")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r21); PHALCON_ALLOC_ZVAL_MM(r22); - phalcon_array_fetch_string(&r22, params, SL("order"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CONCAT_SVS(r21, " ORDER BY ", r22, " "); - phalcon_concat_self(&select, r21 TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r23); + phalcon_array_fetch_string(&r23, params, SL("order"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CONCAT_SVS(r22, " ORDER BY ", r23, " "); + phalcon_concat_self(&select, r22 TSRMLS_CC); } eval_int = phalcon_array_isset_string(params, SL("limit")+1); if (eval_int) { - PHALCON_ALLOC_ZVAL_MM(r23); PHALCON_ALLOC_ZVAL_MM(r24); - phalcon_array_fetch_string(&r24, params, SL("limit"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_2(r23, connection, "_limit", select, r24, PHALCON_NO_CHECK); - PHALCON_CPY_WRT(select, r23); + PHALCON_ALLOC_ZVAL_MM(r25); + phalcon_array_fetch_string(&r25, params, SL("limit"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CALL_METHOD_PARAMS_2(r24, connection, "_limit", select, r25, PHALCON_NO_CHECK); + PHALCON_CPY_WRT(select, r24); } - PHALCON_ALLOC_ZVAL_MM(r25); + PHALCON_ALLOC_ZVAL_MM(r26); p0[0] = connection; p0[1] = params; p0[2] = select; p0[3] = alias; - PHALCON_CALL_SELF_PARAMS(r25, this_ptr, "_getgroupresult", 4, p0); - RETURN_DZVAL(r25); + PHALCON_CALL_SELF_PARAMS(r26, this_ptr, "_getgroupresult", 4, p0); + RETURN_DZVAL(r26); } /** @@ -24983,8 +24996,8 @@ PHP_METHOD(Phalcon_Model_Base, _checkForeignKeys){ int eval_int; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_ALLOC_ZVAL_MM(r0); @@ -25201,8 +25214,8 @@ PHP_METHOD(Phalcon_Model_Base, _checkForeignKeysReverse){ int eval_int; PHALCON_MM_GROW(); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_ALLOC_ZVAL_MM(r0); @@ -26281,8 +26294,8 @@ PHP_METHOD(Phalcon_Model_Base, writeAttribute){ PHP_METHOD(Phalcon_Model_Base, hasOne){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *options = NULL, *manager = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -26292,17 +26305,16 @@ PHP_METHOD(Phalcon_Model_Base, hasOne){ RETURN_NULL(); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addhasone", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addhasone", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -26324,9 +26336,9 @@ PHP_METHOD(Phalcon_Model_Base, hasOne){ PHP_METHOD(Phalcon_Model_Base, belongsTo){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; + zval *options = NULL, *manager = NULL; zval *a0 = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -26342,17 +26354,16 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ PHALCON_CPY_WRT(options, a0); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addbelongsto", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addbelongsto", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -26363,7 +26374,7 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ /** * Setup a relation 1-n between two models - * +* * * * @param mixed $fields @@ -26374,9 +26385,9 @@ PHP_METHOD(Phalcon_Model_Base, belongsTo){ PHP_METHOD(Phalcon_Model_Base, hasMany){ zval *fields = NULL, *reference_model = NULL, *referenced_fields = NULL; - zval *options = NULL; + zval *options = NULL, *manager = NULL; zval *a0 = NULL; - zval *t0 = NULL, *t1 = NULL; + zval *t0 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL, NULL }; PHALCON_MM_GROW(); @@ -26392,17 +26403,16 @@ PHP_METHOD(Phalcon_Model_Base, hasMany){ PHALCON_CPY_WRT(options, a0); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); - if (zend_is_true(t0)) { - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(manager, t0); + if (zend_is_true(manager)) { p0[0] = this_ptr; p0[1] = fields; p0[2] = reference_model; p0[3] = referenced_fields; p0[4] = options; - PHALCON_CALL_METHOD_PARAMS_NORETURN(t1, "addhasmany", 5, p0, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_NORETURN(manager, "addhasmany", 5, p0, PHALCON_NO_CHECK); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "There is not models manager related to this model"); return; @@ -26450,8 +26460,9 @@ PHP_METHOD(Phalcon_Model_Base, __call){ PHALCON_ALLOC_ZVAL_MM(r0); phalcon_get_class(r0, this_ptr TSRMLS_CC); PHALCON_CPY_WRT(model_name, r0); - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Base"), SL("_manager") TSRMLS_CC); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_manager"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(manager, t0); PHALCON_INIT_VAR(c0); @@ -27395,7 +27406,7 @@ PHP_METHOD(Phalcon_Model_MetaData, _initializeMetaData){ /** * Returns table attributes names (fields) * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getAttributes){ @@ -27481,7 +27492,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getPrimaryKeyAttributes){ /** * Returns an arrau of fields which are not part of the primary key * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getNonPrimaryKeyAttributes){ @@ -27524,7 +27535,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getNonPrimaryKeyAttributes){ /** * Returns an array of not null attributes * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getNotNullAttributes){ @@ -27567,7 +27578,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getNotNullAttributes){ /** * Returns attributes and their data types * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getDataTypes){ @@ -27610,7 +27621,7 @@ PHP_METHOD(Phalcon_Model_MetaData, getDataTypes){ /** * Returns attributes which types are numerical * - * @param Phalcon_Model_Base $model +* @param Phalcon_Model_Base $model * @return array */ PHP_METHOD(Phalcon_Model_MetaData, getDataTypesNumeric){ @@ -27763,12 +27774,12 @@ PHP_METHOD(Phalcon_Model_MetaData, reset){ */ /** - * Phalcon_Model_Message message - * - * @param string $message - * @param string $field - * @param string $type - */ +* Phalcon_Model_Message message +* +* @param string $message +* @param string $field +* @param string $type +*/ PHP_METHOD(Phalcon_Model_Message, __construct){ zval *message = NULL, *field = NULL, *type = NULL; @@ -27798,10 +27809,10 @@ PHP_METHOD(Phalcon_Model_Message, __construct){ } /** - * Sets message type - * - * @param string $type - */ +* Sets message type +* +* @param string $type +*/ PHP_METHOD(Phalcon_Model_Message, setType){ zval *type = NULL; @@ -27819,10 +27830,10 @@ PHP_METHOD(Phalcon_Model_Message, setType){ } /** - * Returns message type - * - * @return string - */ +* Returns message type +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getType){ zval *t0 = NULL; @@ -27835,10 +27846,10 @@ PHP_METHOD(Phalcon_Model_Message, getType){ } /** - * Sets verbose message - * - * @param string $message - */ +* Sets verbose message +* +* @param string $message +*/ PHP_METHOD(Phalcon_Model_Message, setMessage){ zval *message = NULL; @@ -27856,10 +27867,10 @@ PHP_METHOD(Phalcon_Model_Message, setMessage){ } /** - * Returns verbose message - * - * @return string - */ +* Returns verbose message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getMessage){ zval *t0 = NULL; @@ -27872,10 +27883,10 @@ PHP_METHOD(Phalcon_Model_Message, getMessage){ } /** - * Sets field name related to message - * - * @param string $field - */ +* Sets field name related to message +* +* @param string $field +*/ PHP_METHOD(Phalcon_Model_Message, setField){ zval *field = NULL; @@ -27893,10 +27904,10 @@ PHP_METHOD(Phalcon_Model_Message, setField){ } /** - * Returns field name related to message - * - * @return string - */ +* Returns field name related to message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, getField){ zval *t0 = NULL; @@ -27909,10 +27920,10 @@ PHP_METHOD(Phalcon_Model_Message, getField){ } /** - * Magic __toString method returns verbose message - * - * @return string - */ +* Magic __toString method returns verbose message +* +* @return string +*/ PHP_METHOD(Phalcon_Model_Message, __toString){ zval *t0 = NULL; @@ -27925,11 +27936,11 @@ PHP_METHOD(Phalcon_Model_Message, __toString){ } /** - * Magic __set_state helps to recover messsages from serialization - * - * @param array $message - * @return Phalcon_Model_Message - */ +* Magic __set_state helps to recover messsages from serialization +* +* @param array $message +* @return Phalcon_Model_Message +*/ PHP_METHOD(Phalcon_Model_Message, __set_state){ zval *message = NULL; @@ -27967,13 +27978,13 @@ PHP_METHOD(Phalcon_Model_Message, __set_state){ /** * Constructor for Phalcon_Model_Manager - * - * @param Phalcon_Config|stdClass $options +* +* @param Phalcon_Config|stdClass $options */ PHP_METHOD(Phalcon_Model_Manager, __construct){ zval *options = NULL, *model_options = NULL; - zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL; + zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL, *a6 = NULL; zval *t0 = NULL; zval *i0 = NULL; @@ -27997,6 +28008,11 @@ PHP_METHOD(Phalcon_Model_Manager, __construct){ PHALCON_INIT_VAR(a4); array_init(a4); + zend_update_property(phalcon_model_manager_ce, this_ptr, SL("_sourceNames"), a4 TSRMLS_CC); + + PHALCON_INIT_VAR(a5); + array_init(a5); + zend_update_property(phalcon_model_manager_ce, this_ptr, SL("_initialized"), a5 TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &options) == FAILURE) { PHALCON_MM_RESTORE(); @@ -28027,11 +28043,11 @@ PHP_METHOD(Phalcon_Model_Manager, __construct){ phalcon_update_property_zval(this_ptr, SL("_options"), model_options TSRMLS_CC); - PHALCON_INIT_VAR(a5); - array_init(a5); - phalcon_array_append(&a5, this_ptr, PHALCON_SEPARATE_PLZ TSRMLS_CC); - add_next_index_stringl(a5, SL("autoload"), 1); - PHALCON_CALL_FUNC_PARAMS_1_NORETURN("spl_autoload_register", a5); + PHALCON_INIT_VAR(a6); + array_init(a6); + phalcon_array_append(&a6, this_ptr, PHALCON_SEPARATE_PLZ TSRMLS_CC); + add_next_index_stringl(a6, SL("autoload"), 1); + PHALCON_CALL_FUNC_PARAMS_1_NORETURN("spl_autoload_register", a6); PHALCON_MM_RESTORE(); } @@ -28454,6 +28470,49 @@ PHP_METHOD(Phalcon_Model_Manager, getModel){ RETURN_CHECK_CTOR(r0); } +/** + * Initializes a model in the model manager + * + * @param Phalcon_Model_Manager $model + */ +PHP_METHOD(Phalcon_Model_Manager, initialize){ + + zval *model = NULL, *class_name = NULL; + zval *r0 = NULL; + zval *t0 = NULL, *t1 = NULL, *t2 = NULL; + int eval_int; + + PHALCON_MM_GROW(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &model) == FAILURE) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + PHALCON_ALLOC_ZVAL_MM(r0); + phalcon_get_class(r0, model TSRMLS_CC); + PHALCON_CPY_WRT(class_name, r0); + + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); + eval_int = phalcon_array_isset(t0, class_name); + if (!eval_int) { + if (phalcon_method_exists_ex(model, SL("initialize") TSRMLS_CC) == SUCCESS) { + PHALCON_CALL_METHOD_NORETURN(model, "initialize", PHALCON_NO_CHECK); + } + + PHALCON_INIT_VAR(t1); + ZVAL_BOOL(t1, 1); + + PHALCON_ALLOC_ZVAL_MM(t2); + phalcon_read_property(&t2, this_ptr, SL("_initialized"), PHALCON_NOISY TSRMLS_CC); + phalcon_array_update(&t2, class_name, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_initialized"), t2 TSRMLS_CC); + } + + PHALCON_MM_RESTORE(); +} + /** * Gets the possible source model name from its class name * @@ -28462,9 +28521,10 @@ PHP_METHOD(Phalcon_Model_Manager, getModel){ */ PHP_METHOD(Phalcon_Model_Manager, getSource){ - zval *model_name = NULL; - zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL; - zval *r0 = NULL; + zval *model_name = NULL, *source_names = NULL, *source_name = NULL; + zval *t0 = NULL, *t1 = NULL; + zval *r0 = NULL, *r1 = NULL; + int eval_int; PHALCON_MM_GROW(); @@ -28473,28 +28533,27 @@ PHP_METHOD(Phalcon_Model_Manager, getSource){ RETURN_NULL(); } - PHALCON_OBSERVE_VAR(t0); - phalcon_read_static_property(&t0, SL("Phalcon_Model_Manager"), SL("_sourceNames") TSRMLS_CC); - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_array_fetch(&t1, t0, model_name, PHALCON_SILENT TSRMLS_CC); - if (!zend_is_true(t1)) { + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_sourceNames"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(source_names, t0); + eval_int = phalcon_array_isset(source_names, model_name); + if (!eval_int) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC_PARAMS_1(r0, "phalcon_text", "uncamelize", model_name); - t2 = zend_read_static_property(phalcon_model_manager_ce, SL("_sourceNames"), PHALCON_FETCH_CLASS_SILENT); - if (Z_TYPE_P(t2) != IS_ARRAY) { - convert_to_array(t2); - } - phalcon_array_update(&t2, model_name, &r0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); - phalcon_update_static_property(SL("phalcon_model_manager_ce"), SL("_sourceNames"), t2 TSRMLS_CC); + PHALCON_CPY_WRT(source_name, r0); + + PHALCON_ALLOC_ZVAL_MM(t1); + phalcon_read_property(&t1, this_ptr, SL("_sourceNames"), PHALCON_NOISY TSRMLS_CC); + phalcon_array_update(&t1, model_name, &source_name, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_sourceNames"), t1 TSRMLS_CC); + RETURN_CHECK_CTOR(source_name); } - PHALCON_OBSERVE_VAR(t3); - phalcon_read_static_property(&t3, SL("Phalcon_Model_Manager"), SL("_sourceNames") TSRMLS_CC); - PHALCON_ALLOC_ZVAL_MM(t4); - phalcon_array_fetch(&t4, t3, model_name, PHALCON_NOISY TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(r1); + phalcon_array_fetch(&r1, source_names, model_name, PHALCON_NOISY TSRMLS_CC); - RETURN_CHECK_CTOR(t4); + RETURN_CHECK_CTOR(r1); } /** @@ -28504,13 +28563,15 @@ PHP_METHOD(Phalcon_Model_Manager, getSource){ */ PHP_METHOD(Phalcon_Model_Manager, getConnection){ - zval *t0 = NULL, *t1 = NULL; + zval *connection = NULL; + zval *t0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(connection, t0); + if (!zend_is_true(connection)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_STATIC(r0, "phalcon_transaction_manager", "isautomatic"); if (zend_is_true(r0)) { @@ -28529,14 +28590,13 @@ PHP_METHOD(Phalcon_Model_Manager, getConnection){ PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CALL_STATIC(r4, "phalcon_db_pool", "getconnection"); - phalcon_update_property_zval(this_ptr, SL("_connection"), r4 TSRMLS_CC); + PHALCON_CPY_WRT(connection, r4); + phalcon_update_property_zval(this_ptr, SL("_connection"), connection TSRMLS_CC); } } - PHALCON_ALLOC_ZVAL_MM(t1); - phalcon_read_property(&t1, this_ptr, SL("_connection"), PHALCON_NOISY TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + RETURN_CHECK_CTOR(connection); } /** @@ -29769,20 +29829,27 @@ PHP_METHOD(Phalcon_Model_MetaData_Session, write){ * * @param Phalcon_Model_Base $model * @param Phalcon_Model_Result $result + * @param Phalcon_Model_Cache $cache */ PHP_METHOD(Phalcon_Model_Resultset, __construct){ - zval *model = NULL, *result = NULL; + zval *model = NULL, *result = NULL, *cache = NULL; PHALCON_MM_GROW(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &model, &result) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &model, &result, &cache) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + if (!cache) { + PHALCON_INIT_VAR(cache); + ZVAL_NULL(cache); + } + phalcon_update_property_zval(this_ptr, SL("_model"), model TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_result"), result TSRMLS_CC); + phalcon_update_property_zval(this_ptr, SL("_cache"), cache TSRMLS_CC); phalcon_update_property_long(this_ptr, SL("_type"), 1 TSRMLS_CC); PHALCON_MM_RESTORE(); @@ -30290,6 +30357,36 @@ PHP_METHOD(Phalcon_Model_Resultset, unserialize){ PHALCON_MM_RESTORE(); } +/** + * Returns the associated cache for the resultset + * + * @return Phalcon_Cache + */ +PHP_METHOD(Phalcon_Model_Resultset, getCache){ + + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_cache"), PHALCON_NOISY TSRMLS_CC); + + RETURN_CHECK_CTOR(t0); +} + +/** + * Returns an instance of the model that is used to generate each of the results + */ +PHP_METHOD(Phalcon_Model_Resultset, getSourceModel){ + + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_model"), PHALCON_NOISY TSRMLS_CC); + + RETURN_CHECK_CTOR(t0); +} + /** * Phalcon_Tag * @@ -31822,21 +31919,23 @@ PHP_METHOD(Phalcon_Tag, image){ */ PHP_METHOD(Phalcon_Response, getInstance){ - zval *t0 = NULL, *t1 = NULL; + zval *instance = NULL; + zval *t0 = NULL; zval *i0 = NULL; PHALCON_MM_GROW(); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Response"), SL("_instance") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(instance, t0); + if (!zend_is_true(instance)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_response_ce); - phalcon_update_static_property(SL("Phalcon_Response"), SL("_instance"), i0 TSRMLS_CC); + PHALCON_CPY_WRT(instance, i0); + phalcon_update_static_property(SL("Phalcon_Response"), SL("_instance"), instance TSRMLS_CC); } - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Response"), SL("_instance") TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + + RETURN_CHECK_CTOR(instance); } /** @@ -31938,7 +32037,7 @@ PHP_METHOD(Phalcon_Response, setHeader){ * Send a raw header to the response * * - * +* * @param string $header * @return Phalcon_Response */ @@ -32106,7 +32205,7 @@ PHP_METHOD(Phalcon_Response, redirect){ /** * Sets HTTP response body - * +* * * * @param string $content @@ -32171,6 +32270,26 @@ PHP_METHOD(Phalcon_Response, getContent){ RETURN_CHECK_CTOR(t0); } +/** + * Sends headers to the client + * + */ +PHP_METHOD(Phalcon_Response, sendHeaders){ + + zval *headers = NULL; + zval *t0 = NULL; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(t0); + phalcon_read_property(&t0, this_ptr, SL("_headers"), PHALCON_NOISY TSRMLS_CC); + PHALCON_CPY_WRT(headers, t0); + if (zend_is_true(headers)) { + PHALCON_CALL_METHOD_NORETURN(headers, "send", PHALCON_NO_CHECK); + } + + PHALCON_MM_RESTORE(); +} + /** * Prints out HTTP response to the client * @@ -32231,26 +32350,28 @@ PHP_METHOD(Phalcon_Response, reset){ */ PHP_METHOD(Phalcon_Request, getInstance){ - zval *t0 = NULL, *t1 = NULL; + zval *instance = NULL; + zval *t0 = NULL; zval *i0 = NULL; PHALCON_MM_GROW(); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Request"), SL("_instance") TSRMLS_CC); - if (!zend_is_true(t0)) { + PHALCON_CPY_WRT(instance, t0); + if (!zend_is_true(instance)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_request_ce); - phalcon_update_static_property(SL("Phalcon_Request"), SL("_instance"), i0 TSRMLS_CC); + PHALCON_CPY_WRT(instance, i0); + phalcon_update_static_property(SL("Phalcon_Request"), SL("_instance"), instance TSRMLS_CC); } - PHALCON_OBSERVE_VAR(t1); - phalcon_read_static_property(&t1, SL("Phalcon_Request"), SL("_instance") TSRMLS_CC); - RETURN_CHECK_CTOR(t1); + + RETURN_CHECK_CTOR(instance); } /** * Overwrites Phalcon_Filter object used to sanitize input data - * +* * * * @param Phalcon_Filter $filter @@ -32350,7 +32471,7 @@ PHP_METHOD(Phalcon_Request, getPost){ /** * Gets variable from $_GET superglobal applying filters if needed - * +* * * * @param string $name @@ -34142,7 +34263,7 @@ PHP_METHOD(Phalcon_Controller_Front, setControllersDir){ /** * Sets models directory. Depending of your platform, always add a trailing slash or backslash - * +* * * * @param string $modelsDir @@ -34659,6 +34780,7 @@ PHP_METHOD(Phalcon_Controller_Front, dispatchLoop){ PHALCON_ALLOC_ZVAL_MM(r10); PHALCON_CALL_METHOD(r10, view, "getcontent", PHALCON_NO_CHECK); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(response, "setcontent", r10, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_NORETURN(response, "sendheaders", PHALCON_NO_CHECK); RETURN_CHECK_CTOR(response); } @@ -35026,7 +35148,7 @@ PHP_METHOD(Phalcon_Flash, error){ /** * Shows a HTML notice/information message * - * +* * * @param string $message * @param string $classes @@ -36883,10 +37005,10 @@ PHP_METHOD(Phalcon_Transaction, getMessages){ } /** - * Checks whether internal connection is under an active transaction - * - * @return boolean - */ +* Checks whether internal connection is under an active transaction +* +* @return boolean +*/ PHP_METHOD(Phalcon_Transaction, isValid){ zval *r0 = NULL; @@ -37320,7 +37442,6 @@ PHP_MINIT_FUNCTION(phalcon){ INIT_CLASS_ENTRY(ce_model_base, "Phalcon_Model_Base", phalcon_model_base_functions); phalcon_model_base_ce = zend_register_internal_class(&ce_model_base TSRMLS_CC); - zend_declare_property_bool(phalcon_model_base_ce, SL("_initialized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_model_base_ce, SL("_uniqueKey"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_model_base_ce, SL("_connection"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_model_base_ce, SL("_schema"), "", ZEND_ACC_PROTECTED TSRMLS_CC); @@ -37387,7 +37508,8 @@ PHP_MINIT_FUNCTION(phalcon){ zend_declare_property_null(phalcon_model_manager_ce, SL("_hasOne"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_belongsTo"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(phalcon_model_manager_ce, SL("_sourceNames"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); + zend_declare_property_null(phalcon_model_manager_ce, SL("_sourceNames"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(phalcon_model_manager_ce, SL("_initialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_manager_ce, SL("_default"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); INIT_CLASS_ENTRY(ce_model_metadata_memory, "Phalcon_Model_MetaData_Memory", phalcon_model_metadata_memory_functions); @@ -37407,6 +37529,7 @@ PHP_MINIT_FUNCTION(phalcon){ zend_declare_property_null(phalcon_model_resultset_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_result"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(phalcon_model_resultset_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_model_resultset_ce, SL("_pointer"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_count"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_model_resultset_ce, SL("_activeRow"), ZEND_ACC_PROTECTED TSRMLS_CC); diff --git a/release/phalcon.h b/release/phalcon.h index 578465ea6c4..027067988e4 100644 --- a/release/phalcon.h +++ b/release/phalcon.h @@ -710,6 +710,7 @@ PHP_METHOD(Phalcon_Model_Manager, getModelsDir); PHP_METHOD(Phalcon_Model_Manager, isModel); PHP_METHOD(Phalcon_Model_Manager, load); PHP_METHOD(Phalcon_Model_Manager, getModel); +PHP_METHOD(Phalcon_Model_Manager, initialize); PHP_METHOD(Phalcon_Model_Manager, getSource); PHP_METHOD(Phalcon_Model_Manager, getConnection); PHP_METHOD(Phalcon_Model_Manager, addHasOne); @@ -759,6 +760,8 @@ PHP_METHOD(Phalcon_Model_Resultset, getLast); PHP_METHOD(Phalcon_Model_Resultset, isFresh); PHP_METHOD(Phalcon_Model_Resultset, serialize); PHP_METHOD(Phalcon_Model_Resultset, unserialize); +PHP_METHOD(Phalcon_Model_Resultset, getCache); +PHP_METHOD(Phalcon_Model_Resultset, getSourceModel); PHP_METHOD(Phalcon_Tag, setDispatcher); PHP_METHOD(Phalcon_Tag, _getDispatcher); @@ -799,6 +802,7 @@ PHP_METHOD(Phalcon_Response, redirect); PHP_METHOD(Phalcon_Response, setContent); PHP_METHOD(Phalcon_Response, appendContent); PHP_METHOD(Phalcon_Response, getContent); +PHP_METHOD(Phalcon_Response, sendHeaders); PHP_METHOD(Phalcon_Response, send); PHP_METHOD(Phalcon_Response, reset); @@ -2358,6 +2362,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_getmodel, 0, 0, 1) ZEND_ARG_INFO(0, modelName) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_initialize, 0, 0, 1) + ZEND_ARG_INFO(0, model) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_manager_getsource, 0, 0, 1) ZEND_ARG_INFO(0, modelName) ZEND_END_ARG_INFO() @@ -2461,6 +2469,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_resultset___construct, 0, 0, 2) ZEND_ARG_INFO(0, model) ZEND_ARG_INFO(0, result) + ZEND_ARG_INFO(0, cache) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_model_resultset_seek, 0, 0, 1) @@ -3512,8 +3521,8 @@ PHALCON_INIT_FUNCS(phalcon_model_query_functions){ PHALCON_INIT_FUNCS(phalcon_model_base_functions){ PHP_ME(Phalcon_Model_Base, __construct, arginfo_phalcon_model_base___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_CTOR) - PHP_ME(Phalcon_Model_Base, setManager, arginfo_phalcon_model_base_setmanager, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Model_Base, getManager, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Model_Base, setManager, arginfo_phalcon_model_base_setmanager, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Base, getManager, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Base, _connect, NULL, ZEND_ACC_PROTECTED) PHP_ME(Phalcon_Model_Base, getAttributes, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Base, getPrimaryKeyAttributes, NULL, ZEND_ACC_PUBLIC) @@ -3633,6 +3642,7 @@ PHALCON_INIT_FUNCS(phalcon_model_manager_functions){ PHP_ME(Phalcon_Model_Manager, isModel, arginfo_phalcon_model_manager_ismodel, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, load, arginfo_phalcon_model_manager_load, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getModel, arginfo_phalcon_model_manager_getmodel, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Manager, initialize, arginfo_phalcon_model_manager_initialize, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getSource, arginfo_phalcon_model_manager_getsource, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, getConnection, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Manager, addHasOne, arginfo_phalcon_model_manager_addhasone, ZEND_ACC_PUBLIC) @@ -3694,6 +3704,8 @@ PHALCON_INIT_FUNCS(phalcon_model_resultset_functions){ PHP_ME(Phalcon_Model_Resultset, isFresh, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Resultset, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Model_Resultset, unserialize, arginfo_phalcon_model_resultset_unserialize, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Resultset, getCache, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Model_Resultset, getSourceModel, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -3740,6 +3752,7 @@ PHALCON_INIT_FUNCS(phalcon_response_functions){ PHP_ME(Phalcon_Response, setContent, arginfo_phalcon_response_setcontent, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, appendContent, arginfo_phalcon_response_appendcontent, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, getContent, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Response, sendHeaders, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, send, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Response, reset, NULL, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_FE_END diff --git a/unit-tests/ModelsManagerTest.php b/unit-tests/ModelsManagerTest.php index adcfb18920c..20e2ac1aeeb 100755 --- a/unit-tests/ModelsManagerTest.php +++ b/unit-tests/ModelsManagerTest.php @@ -28,9 +28,9 @@ public function testManager(){ $modelManager->setModelsDir($modelsDir); $this->assertEquals($modelManager->getModelsDir(), $modelsDir); - + $isModel = $modelManager->isModel('NoExiste'); - $this->assertFalse($isModel); + $this->assertFalse($isModel); $isModel = $modelManager->isModel('Personas'); $this->assertTrue($isModel); diff --git a/unit-tests/ModelsMetadataAdaptersTest.php b/unit-tests/ModelsMetadataAdaptersTest.php index 363fbe9152e..c1f0d63ec82 100644 --- a/unit-tests/ModelsMetadataAdaptersTest.php +++ b/unit-tests/ModelsMetadataAdaptersTest.php @@ -9,7 +9,7 @@ | This source file is subject to the New BSD License that is bundled | | with this package in the file docs/LICENSE.txt. | | | - | If you did not receive a copy of the license and are unable to | + | If you did not receive a copy of the licnse and are unable to | | obtain it through the world-wide-web, please send an email | | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ @@ -167,7 +167,7 @@ public function testMetadataApc(){ } - public function testMetadataConfig(){ + public function testMetadataConfigApc(){ apc_delete('$PMM$my-local-app'); @@ -177,6 +177,8 @@ public function testMetadataConfig(){ $options->metadata->suffix = 'my-local-app'; $options->metadata->lifetime = 60; + Phalcon_Model_Manager::reset(); + $manager = new Phalcon_Model_Manager($options); $metaData = $manager->getMetaData(); diff --git a/unit-tests/ModelsTest.php b/unit-tests/ModelsTest.php index 8dbd5249375..fc58cb9a0d7 100755 --- a/unit-tests/ModelsTest.php +++ b/unit-tests/ModelsTest.php @@ -46,6 +46,8 @@ public function testModelsPostgresql(){ protected function _executeTests(){ + Phalcon_Model_Manager::reset(); + $modelManager = new Phalcon_Model_Manager(); $modelManager->setModelsDir('unit-tests/models/'); @@ -61,7 +63,7 @@ protected function _executeTests(){ $connection = $Personas->getConnection(); $this->assertEquals($connection, Phalcon_Db_Pool::getConnection()); - $manager = People::getManager(); + $manager = $Personas->getManager(); $this->assertEquals(get_class($manager), 'Phalcon_Model_Manager'); //Count tests @@ -238,4 +240,4 @@ protected function _executeTests(){ } -} \ No newline at end of file +} diff --git a/unit-tests/cache/testresultset b/unit-tests/cache/testresultset index a1462b92e4e..500c0089ac9 100644 Binary files a/unit-tests/cache/testresultset and b/unit-tests/cache/testresultset differ diff --git a/unit-tests/logs/test-db.log b/unit-tests/logs/test-db.log index 797a3281c04..2d7851a9d51 100644 --- a/unit-tests/logs/test-db.log +++ b/unit-tests/logs/test-db.log @@ -1,3 +1,3 @@ -[Tue, 26 Jun 12 23:57:36 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 3 -[Tue, 26 Jun 12 23:57:36 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 10 -[Tue, 26 Jun 12 23:57:36 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 1 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 3 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 10 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] [Resource id #127] SELECT * FROM personas LIMIT 1 diff --git a/unit-tests/logs/test.log b/unit-tests/logs/test.log index 03bbb2ab7c8..15c9140095d 100644 --- a/unit-tests/logs/test.log +++ b/unit-tests/logs/test.log @@ -1,5 +1,5 @@ -[Tue, 26 Jun 12 23:57:34 -0500][DEBUG] Hello 1 -[Tue, 26 Jun 12 23:57:34 -0500][DEBUG] Hello 2 -[Tue, 26 Jun 12 23:57:34 -0500][DEBUG] Hello 3 -[Tue, 26 Jun 12 23:57:34 -0500][DEBUG] Hello 4 -[Tue, 26 Jun 12 23:57:34 -0500][DEBUG] Hello 5 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] Hello 1 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] Hello 2 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] Hello 3 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] Hello 4 +[Sat, 30 Jun 12 12:14:01 -0500][DEBUG] Hello 5