Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.0] where() method tidy up #1414

Merged
merged 1 commit into from
Oct 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 3 additions & 33 deletions ext/mvc/model/query/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,6 @@ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, rightJoin){
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where){

zval *conditions, *bind_params = NULL, *bind_types = NULL;
zval *current_bind_params, *merged_params = NULL;
zval *current_bind_types, *merged_types = NULL;

PHALCON_MM_GROW();

Expand All @@ -606,38 +604,10 @@ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where){
phalcon_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC);

/**
* Merge the bind params to the current ones
* Override the bind params and bind types to the current ones
*/
if (Z_TYPE_P(bind_params) == IS_ARRAY) {

PHALCON_OBS_VAR(current_bind_params);
phalcon_read_property_this(&current_bind_params, this_ptr, SL("_bindParams"), PH_NOISY_CC);
if (Z_TYPE_P(current_bind_params) == IS_ARRAY) {
PHALCON_INIT_VAR(merged_params);
phalcon_add_function(merged_params, bind_params, current_bind_params TSRMLS_CC);
} else {
PHALCON_CPY_WRT(merged_params, bind_params);
}

phalcon_update_property_this(this_ptr, SL("_bindParams"), merged_params TSRMLS_CC);
}

/**
* Merge the bind types to the current ones
*/
if (Z_TYPE_P(bind_types) == IS_ARRAY) {

PHALCON_OBS_VAR(current_bind_types);
phalcon_read_property_this(&current_bind_types, this_ptr, SL("_bindTypes"), PH_NOISY_CC);
if (Z_TYPE_P(current_bind_types) == IS_ARRAY) {
PHALCON_INIT_VAR(merged_types);
phalcon_add_function(merged_params, bind_types, current_bind_types TSRMLS_CC);
} else {
PHALCON_CPY_WRT(merged_types, bind_types);
}

phalcon_update_property_this(this_ptr, SL("_bindTypes"), merged_types TSRMLS_CC);
}
phalcon_update_property_this(this_ptr, SL("_bindParams"), bind_params TSRMLS_CC);
phalcon_update_property_this(this_ptr, SL("_bindTypes"), bind_types TSRMLS_CC);

RETURN_THIS();
}
Expand Down